当前位置: 首页>>代码示例>>PHP>>正文


PHP ServiceLocatorInterface::get方法代码示例

本文整理汇总了PHP中Zend\ServiceManager\ServiceLocatorInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceLocatorInterface::get方法的具体用法?PHP ServiceLocatorInterface::get怎么用?PHP ServiceLocatorInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\ServiceManager\ServiceLocatorInterface的用法示例。


在下文中一共展示了ServiceLocatorInterface::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createService

 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sm)
 {
     $config = $sm->get('config');
     if (isset($config['session'])) {
         $session = $config['session'];
         $sessionConfig = null;
         if (isset($session['config'])) {
             $class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
             $options = isset($session['config']['options']) ? $session['config']['options'] : array();
             $sessionConfig = new $class();
             $sessionConfig->setOptions($options);
         }
         $sessionStorage = null;
         if (isset($session['storage'])) {
             $class = $session['storage'];
             $sessionStorage = new $class();
         }
         $sessionSaveHandler = null;
         if (isset($session['save_handler'])) {
             // class should be fetched from service manager since it will require constructor arguments
             $sessionSaveHandler = $sm->get($session['save_handler']);
         }
         $sessionManager = new self($sessionConfig, $sessionStorage, $sessionSaveHandler);
     } else {
         $sessionManager = new self();
     }
     \Zend\Session\Container::setDefaultManager($sessionManager);
     return $sessionManager;
 }
开发者ID:daemonalchemist,项目名称:atp-core,代码行数:29,代码来源:SessionManager.php

示例2: createService

 /**
  * Factory method.
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $service = new PicService();
     $service->setEntityManager($serviceLocator->get('Doctrine\\ORM\\EntityManager'));
     $service->setAuthService($serviceLocator->get('zfcuser_auth_service'));
     return $service;
 }
开发者ID:Primetron,项目名称:Edusoft,代码行数:13,代码来源:PicServiceFactory.php

示例3: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $router = $serviceLocator->get('Router');
     $application = $serviceLocator->get('Application');
     $options = $serviceLocator->get('zfcuser_module_options');
     return new RedirectCallback($application, $router, $options);
 }
开发者ID:omusico,项目名称:ScnSocialAuth,代码行数:7,代码来源:RedirectCallbackFactory.php

示例4: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $em = $serviceLocator->get('doctrine.entitymanager.orm_default');
     $options = $serviceLocator->get('BiBoBlogOptions');
     $form = new \BiBoBlog\Form\BiBoBlogForm($em, $options);
     return $form;
 }
开发者ID:vn00186388,项目名称:bibo-test,代码行数:7,代码来源:BiBoBlogFormFactory.php

示例5: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $adapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $entity = $serviceLocator->get('Techtree\\Entity\\Research');
     $table = new ResearchTable($adapter, $entity);
     return $table;
 }
开发者ID:nouron,项目名称:nouron,代码行数:7,代码来源:ResearchTableFactory.php

示例6: createService

 public function createService(ServiceLocatorInterface $sm)
 {
     $service = new TableService();
     $service->setCityCodesTable($sm->get('city-codes-table'));
     $service->setListingsTable($sm->get('listings-table'));
     return $service;
 }
开发者ID:jordiwes,项目名称:zf2.unlikelysource.org,代码行数:7,代码来源:TableServiceFactory.php

示例7: createService

 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $pluginManager = $serviceLocator->get('Phpro\\MailManager\\PluginManager');
     $adapter = $serviceLocator->get('Phpro\\MailManager\\DefaultAdapter');
     $instance = new Instance($pluginManager, $adapter);
     return $instance;
 }
开发者ID:phpro,项目名称:zf-mail-manager,代码行数:14,代码来源:MailManager.php

示例8: createService

 /**
  * Create and return a Console adapter instance.
  * In case we're not in a Console environment, return a dummy stdClass object.
  *
  * In order to disable adapter auto-detection and use a specific adapter (and charset),
  * add the following fields to application configuration, for example:
  *
  *     'console' => array(
  *         'adapter' => 'MyConsoleAdapter',     // always use this console adapter
  *         'charset' => 'MyConsoleCharset',     // always use this console charset
  *      ),
  *      'service_manager' => array(
  *          'invokables' => array(
  *              'MyConsoleAdapter' => 'Zend\Console\Adapter\Windows',
  *              'MyConsoleCharset' => 'Zend\Console\Charset\DESCG',
  *          )
  *      )
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return AdapterInterface|stdClass
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     // First, check if we're actually in a Console environment
     if (!Console::isConsole()) {
         // SM factory cannot currently return null, so we return dummy object
         return new stdClass();
     }
     // Read app config and determine Console adapter to use
     $config = $serviceLocator->get('Config');
     if (!empty($config['console']) && !empty($config['console']['adapter'])) {
         // use the adapter supplied in application config
         $adapter = $serviceLocator->get($config['console']['adapter']);
     } else {
         // try to detect best console adapter
         $adapter = Console::detectBestAdapter();
         $adapter = new $adapter();
     }
     // check if we have a valid console adapter
     if (!$adapter instanceof AdapterInterface) {
         // SM factory cannot currently return null, so we convert it to dummy object
         return new stdClass();
     }
     // Optionally, change Console charset
     if (!empty($config['console']) && !empty($config['console']['charset'])) {
         // use the charset supplied in application config
         $charset = $serviceLocator->get($config['console']['charset']);
         $adapter->setCharset($charset);
     }
     return $adapter;
 }
开发者ID:Nurik4249,项目名称:torrentpier,代码行数:51,代码来源:ConsoleAdapterFactory.php

示例9: createService

 /**
  * Create Service Factory
  * 
  * @param ServiceLocatorInterface $serviceLocator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $adapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $entity = $serviceLocator->get('Blog\\Entity\\Blog');
     $table = new BlogTable($adapter, $entity);
     return $table;
 }
开发者ID:andreaszobl,项目名称:software,代码行数:12,代码来源:BlogTableFactory.php

示例10: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $options = $serviceLocator->get('cdiuser_options');
     $em = $serviceLocator->get('zfcuser_doctrine_em');
     $userSession = new \CdiUser\Service\UserSession($options, $em, $serviceLocator);
     return $userSession;
 }
开发者ID:cincarnato,项目名称:cdiuser,代码行数:7,代码来源:UserSessionFactory.php

示例11: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     // The parameters in Doctrine 2 and ZF2 are slightly different.
     // Below is an example how we can reuse the db settings
     $doctrineDbConfig = (array) $config['db'];
     $doctrineDbConfig['driver'] = strtolower($doctrineDbConfig['driver']);
     if (!isset($doctrineDbConfig['dbname'])) {
         $doctrineDbConfig['dbname'] = $doctrineDbConfig['database'];
     }
     if (!isset($doctrineDbConfig['host'])) {
         $doctrineDbConfig['host'] = $doctrineDbConfig['hostname'];
     }
     if (!isset($doctrineDbConfig['user'])) {
         $doctrineDbConfig['user'] = $doctrineDbConfig['username'];
     }
     $doctrineConfig = Setup::createAnnotationMetadataConfiguration($config['doctrine']['entity_path'], true);
     $entityManager = DoctrineEntityManager::create($doctrineDbConfig, $doctrineConfig);
     if (isset($config['doctrine']['initializers'])) {
         $eventManager = $entityManager->getEventManager();
         foreach ($config['doctrine']['initializers'] as $initializer) {
             $eventClass = new DoctrineEvent(new $initializer(), $serviceLocator);
             $eventManager->addEventListener(\Doctrine\ORM\Events::postLoad, $eventClass);
         }
     }
     if ($serviceLocator->has('doctrine-profiler')) {
         $profiler = $serviceLocator->get('doctrine-profiler');
         $entityManager->getConfiguration()->setSQLLogger($profiler);
     }
     return $entityManager;
 }
开发者ID:gsokolowski,项目名称:learnzf2,代码行数:31,代码来源:EntityManager.php

示例12: createService

 /**
  * {@inheritDoc}
  *
  * @throws RuntimeException
  * @return AnnotationBuilder
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /* @var $options FormAnnotationBuilder */
     $options = $serviceLocator->get(FormAnnotationBuilder::class);
     $cache = $serviceLocator->has($options->getCache()) ? $serviceLocator->get($options->getCache()) : null;
     $builder = new AnnotationBuilder($cache);
     if ($serviceLocator->has('FormElementManager')) {
         $serviceLocator->get('FormElementManager')->injectFactory($builder);
     }
     foreach ($options->getAnnotations() as $annotation) {
         $builder->getAnnotationParser()->registerAnnotation($annotation);
     }
     $events = $builder->getEventManager();
     foreach ($options->getListeners() as $listener) {
         $listener = $serviceLocator->has($listener) ? $serviceLocator->get($listener) : new $listener();
         if (!$listener instanceof ListenerAggregateInterface) {
             throw new RuntimeException(sprintf('Invalid event listener (%s) provided', get_class($listener)));
         }
         $events->attach($listener);
     }
     if (null !== $options->getPreserveDefinedOrder()) {
         $builder->setPreserveDefinedOrder($options->getPreserveDefinedOrder());
     }
     return $builder;
 }
开发者ID:coolms,项目名称:common,代码行数:31,代码来源:AnnotationBuilderFactory.php

示例13: getMainItems

 /**
  * Retrieve array of menu items
  *
  * Returns only items with 'main' equal to TRUE
  *
  * @return array
  */
 public function getMainItems()
 {
     $result = array_filter($this->serviceLocator->get('config')['nav'], function ($value) {
         return isset($value['main']) && (bool) $value['main'];
     });
     return $result;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Navigation.php

示例14: _getServTranslator

 /**
  * Retourne le translator.
  *
  * @var \Zend\I18n\Translator\Translator
  */
 public function _getServTranslator()
 {
     if (!$this->_servTranslator) {
         $this->_servTranslator = $this->_serviceLocator->get('translator');
     }
     return $this->_servTranslator;
 }
开发者ID:antarus,项目名称:mystra-pve,代码行数:12,代码来源:EvenementsTemplateRolesGrid.php

示例15: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var \Zend\Mvc\Application $app */
     $app = $serviceLocator->get('Application');
     /** @var \Zend\Mvc\Router\Http\RouteMatch $routeMatch */
     $routeMatch = $app->getMvcEvent()->getRouteMatch();
     if ($routeMatch->getParam('viewModel')) {
         $viewModel = $serviceLocator->get($routeMatch->getParam('viewModel'));
         if (!$viewModel instanceof ViewModel) {
             throw new \RuntimeException('ViewModel must be instance of ' . ViewModel::class);
         }
     } else {
         $viewModel = new ViewModel();
     }
     if (!$viewModel->getTemplate()) {
         $template = $routeMatch->getParam('template');
         if ($template) {
             if (!is_string($template)) {
                 throw new \RuntimeException('Parameter template must be string');
             }
             $viewModel->setTemplate($template);
         }
     }
     return $viewModel;
 }
开发者ID:sebaks,项目名称:zend-mvc-controller,代码行数:25,代码来源:ViewModelFactory.php


注:本文中的Zend\ServiceManager\ServiceLocatorInterface::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。