<?php
/**
 * Trait implementing Taggable ContentManager Interface
 *
 * @author Elze Kool <info@visualmedia.nl>
 */

namespace VisualM\TagManagerBundle\Content;

/**
 * Trait implementing Taggable ContentManager Interface
 */
trait TaggableContentManagerTrait
{
    
    public abstract function getIndex(array $options = array(), array $order = array(), $limit = null, $offset = 0);
    protected abstract function getEntityName();

    /**
     * Get list of Content Id's that are managed by this repository
     *
     * @return array Content Ids
     */
    public function getContentIds()
    {
        $content_ids = [];
        foreach($this->getIndex() as $entity) {
            $content_ids[] = $entity->getContentId();
        }
        return $content_ids;
    }

    /**
     * Check if this ContentManager handles the given entity
     * 
     * @param TaggableContentInterface $entity Entity
     *
     * @return bool Handles entity
     */
    public function isEntityHandled(TaggableContentInterface $entity)
    {
        return (is_a($entity, $this->getEntityName()));
    }

}
