vendor/ezsystems/ezpublish-kernel/eZ/Bundle/EzPublishIOBundle/ApiLoader/HandlerFactory.php line 45

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) eZ Systems AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. namespace eZ\Bundle\EzPublishIOBundle\ApiLoader;
  7. use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
  8. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  9. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  10. /**
  11.  * Factory of IO handlers, given an alias.
  12.  */
  13. class HandlerFactory implements ContainerAwareInterface
  14. {
  15.     use ContainerAwareTrait;
  16.     /**
  17.      * Map of handler id to handler service id.
  18.      *
  19.      * @var array
  20.      */
  21.     private $handlersMap = [];
  22.     public function setHandlersMap($handlersMap)
  23.     {
  24.         $this->handlersMap $handlersMap;
  25.     }
  26.     /**
  27.      * @param string $handlerName
  28.      *
  29.      * @return object an instance of the requested handler
  30.      *
  31.      * @throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException If the requested handler doesn't exist
  32.      */
  33.     public function getConfiguredHandler($handlerName)
  34.     {
  35.         if (!isset($this->handlersMap[$handlerName])) {
  36.             throw new InvalidConfigurationException("Unknown handler $handlerName");
  37.         }
  38.         return $this->container->get($this->handlersMap[$handlerName]);
  39.     }
  40. }