<?php
/**
 * Taggable Manager Registry
 *
 * @author Elze Kool <info@visualmedia.nl>
 */

namespace VisualM\TagManagerBundle\Util;

use VisualM\TagManagerBundle\Content\TaggableContentManagerInterface;

/**
 * Taggable Manager Registry
 *
 * Registry that is used to hold the Managers that provide TaggableContent
 *
 * @author Elze Kool <info@visualmedia.nl>
 */
class TaggableManagerRegistry
{
    
    /**
     * Registrated managers
     * @var array
     */
    protected $managers = [];

    /**
     * Register Manager
     *
     * @param string                          $name    Name
     * @param TaggableContentManagerInterface $manager Manager
     */
    public function registerManager($name, TaggableContentManagerInterface $manager)
    {
        $this->managers[$name] = $manager;
    }

    /**
     * Get registrated Manager by Name
     * 
     * @param string $name Name
     *
     * @return TaggableContentManagerInterface|null Manager if registrated, null if not found
     */
    public function getManager($name)
    {
        return isset($this->managers[$name]) ? $this->managers[$name] : null;
    }

    /**
     * Get registrated manager names
     *
     * @return array Names
     */
    public function getRegistratedNames()
    {
        return array_keys($this->managers);
    }

}
