createService() public method

For use with zend-servicemanager v2; proxies to __invoke().
public createService ( Zend\ServiceManager\ServiceLocatorInterface $container ) : Zend\ServiceManager\AbstractPluginManager
$container Zend\ServiceManager\ServiceLocatorInterface
return Zend\ServiceManager\AbstractPluginManager
Exemplo n.º 1
0
 /**
  * Create and return the MVC controller plugin manager
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return FormElementManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $plugins = parent::createService($serviceLocator);
     $plugins->addPeeringServiceManager($serviceLocator);
     $plugins->setRetrieveFromPeeringManagerFirst(true);
     return $plugins;
 }
 /**
  * @inheritdoc
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return \Zend\ServiceManager\AbstractPluginManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $manager = parent::createService($serviceLocator);
     if ($serviceLocator instanceof ServiceManager) {
         $manager->addPeeringServiceManager($serviceLocator);
     }
     return $manager;
 }
Exemplo n.º 3
0
 /**
  * Create and return the view helper manager
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ViewHelperInterface
  * @throws Exception\RuntimeException
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $plugins = parent::createService($serviceLocator);
     foreach ($this->defaultHelperMapClasses as $configClass) {
         if (is_string($configClass) && class_exists($configClass)) {
             $config = new $configClass();
             if (!$config instanceof ConfigInterface) {
                 throw new Exception\RuntimeException(sprintf('Invalid service manager configuration class provided; received "%s", expected class implementing %s', $configClass, 'Zend\\ServiceManager\\ConfigInterface'));
             }
             $config->configureServiceManager($plugins);
         }
     }
     // Configure URL view helper with router
     $plugins->setFactory('url', function () use($serviceLocator) {
         $helper = new ViewHelper\Url();
         $router = Console::isConsole() ? 'HttpRouter' : 'Router';
         $helper->setRouter($serviceLocator->get($router));
         $match = $serviceLocator->get('application')->getMvcEvent()->getRouteMatch();
         if ($match instanceof RouteMatch) {
             $helper->setRouteMatch($match);
         }
         return $helper;
     });
     $plugins->setFactory('basepath', function () use($serviceLocator) {
         $config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array();
         $basePathHelper = new ViewHelper\BasePath();
         if (Console::isConsole() && isset($config['view_manager']) && isset($config['view_manager']['base_path_console'])) {
             $basePathHelper->setBasePath($config['view_manager']['base_path_console']);
             return $basePathHelper;
         }
         if (isset($config['view_manager']) && isset($config['view_manager']['base_path'])) {
             $basePathHelper->setBasePath($config['view_manager']['base_path']);
             return $basePathHelper;
         }
         $request = $serviceLocator->get('Request');
         if (is_callable(array($request, 'getBasePath'))) {
             $basePathHelper->setBasePath($request->getBasePath());
         }
         return $basePathHelper;
     });
     /**
      * Configure doctype view helper with doctype from configuration, if available.
      *
      * Other view helpers depend on this to decide which spec to generate their tags
      * based on. This is why it must be set early instead of later in the layout phtml.
      */
     $plugins->setFactory('doctype', function () use($serviceLocator) {
         $config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array();
         $config = isset($config['view_manager']) ? $config['view_manager'] : array();
         $doctypeHelper = new ViewHelper\Doctype();
         if (isset($config['doctype']) && $config['doctype']) {
             $doctypeHelper->setDoctype($config['doctype']);
         }
         return $doctypeHelper;
     });
     return $plugins;
 }
 /**
  * {@inheritDoc}
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var $serviceListener \Zend\ModuleManager\Listener\ServiceListener */
     $serviceListener = $serviceLocator->get('ServiceListener');
     // This will allow to register new serializers easily, either by implementing the SerializerProviderInterface
     // in your Module.php file, or by adding the "serializers" key in your module.config.php file
     $serviceListener->addServiceManager($serviceLocator, 'serializers', 'Zend\\ModuleManager\\Feature\\SerializerProviderInterface', 'getSerializerConfig');
     return parent::createService($serviceLocator);
 }
 /**
  * Create and return the view helper manager
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return \Zend_View_Helper_Interface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $plugins = parent::createService($serviceLocator);
     $plugins->setFactory('viewRenderer', function ($sm) use($serviceLocator) {
         $renderer = new \HumusMvc\Controller\Action\Helper\ViewRenderer();
         $renderer->setServiceLocator($serviceLocator);
         return $renderer;
     });
     return $plugins;
 }
 /**
  * Create and return the MVC controller plugin manager
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return FormElementManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $plugins = parent::createService($serviceLocator);
     if ($serviceLocator->has('Di')) {
         $di = $serviceLocator->get('Di');
         $im = $di->instanceManager();
         if (!$im->getTypePreferences('Zend\\Form\\FormInterface')) {
             $form = new Form();
             $im->setTypePreference('Zend\\Form\\FormInterface', array($form));
         }
         $plugins->addPeeringServiceManager($serviceLocator);
         $plugins->setRetrieveFromPeeringManagerFirst(true);
     }
     return $plugins;
 }
Exemplo n.º 7
0
 /**
  * Create and return the view helper manager
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return \Zend_View_Helper_Interface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $plugins = parent::createService($serviceLocator);
     // override translate view helper, if translator is created by service locator
     if ($serviceLocator->has('Translator')) {
         $plugins->setFactory('translate', function ($sm) use($serviceLocator) {
             $translateViewHelper = new \Zend_View_Helper_Translate($serviceLocator->get('Translator'));
             return $translateViewHelper;
         });
     }
     if ($serviceLocator->has('Navigation')) {
         $plugins->setFactory('navigation', function ($sm) use($serviceLocator) {
             $navigationViewHelper = new \HumusMvc\View\Helper\Navigation();
             $navigationViewHelper->setServiceLocator($serviceLocator);
             return $navigationViewHelper;
         });
     }
     return $plugins;
 }
 /**
  * Create and return the validator plugin manager
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return \Zend\Validator\ValidatorPluginManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $plugins = parent::createService($serviceLocator);
     return $plugins;
 }
 /**
  * @param ServiceLocatorInterface $serviceLocator
  * @return FunctionProvider
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $functions = parent::createService($serviceLocator);
     $functions->addAbstractFactory(FunctionAbstractFactory::CLASS);
     return $functions;
 }