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


PHP ServiceLocatorInterface::setService方法代码示例

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


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

示例1: setUp

 /**
  * Set up service manager and database configuration.
  *
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     $serviceManagerConfig = new Config(['factories' => ['SphinxSearch\\Db\\Adapter\\Adapter' => 'SphinxSearch\\Db\\Adapter\\AdapterServiceFactory'], 'alias' => ['sphinxql' => 'SphinxSearch\\Db\\Adapter\\Adapter']]);
     $this->serviceManager = new ServiceManager();
     $serviceManagerConfig->configureServiceManager($this->serviceManager);
     $this->serviceManager->setService('Config', ['sphinxql' => ['driver' => 'pdo_mysql']]);
 }
开发者ID:ripaclub,项目名称:sphinxsearch,代码行数:12,代码来源:AdapterServiceFactoryTest.php

示例2: setUp

 public function setUp()
 {
     $this->serviceManager = new ServiceManager(new Config(array('factories' => array('SphinxSearch\\Db\\Adapter\\Adapter' => 'SphinxSearch\\Db\\Adapter\\AdapterServiceFactory'), 'aliases' => array('sphinxql' => 'SphinxSearch\\Db\\Adapter\\Adapter'))));
     $this->serviceManager->setService('Config', array('sphinxql' => $this->config));
     $this->adapter = $this->serviceManager->get('sphinxql');
     $this->search = new Search($this->adapter);
     $this->sql = $this->search->getSql();
 }
开发者ID:joacub,项目名称:sphinxsearch,代码行数:8,代码来源:AbstractIntegrationTest.php

示例3: setUp

 public function setUp()
 {
     $serviceManagerConfig = new Config(['factories' => ['SphinxSearch\\Db\\Adapter\\Adapter' => 'SphinxSearch\\Db\\Adapter\\AdapterServiceFactory'], 'aliases' => ['sphinxql' => 'SphinxSearch\\Db\\Adapter\\Adapter']]);
     $this->serviceManager = new ServiceManager();
     $serviceManagerConfig->configureServiceManager($this->serviceManager);
     $this->serviceManager->setService('Config', ['sphinxql' => $this->config]);
     $this->adapter = $this->serviceManager->get('sphinxql');
     $this->search = new Search($this->adapter);
     $this->sql = $this->search->getSql();
 }
开发者ID:ripaclub,项目名称:sphinxsearch,代码行数:10,代码来源:AbstractIntegrationTest.php

示例4: setSiteAccess

 public function setSiteAccess()
 {
     // init session
     $this->serviceManager->get('session');
     // set user context
     $container = new Container('initialized');
     $this->serviceManager->setService('user', new User($container->userId));
     $this->siteAccess = SiteaccessFactory::factory($this->serviceManager, $this->routeMatch->getParam('context'));
     return $this;
 }
开发者ID:pkamps,项目名称:basexms,代码行数:10,代码来源:Application.php

示例5: createService

 /**
  * @param ServiceLocatorInterface $serviceLocator
  * @return MvcTranslator
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     // Assume that if a user has registered a service for the
     // TranslatorInterface, it must be valid
     if ($serviceLocator->has('Zend\\I18n\\Translator\\TranslatorInterface')) {
         return new MvcTranslator($serviceLocator->get('Zend\\I18n\\Translator\\TranslatorInterface'));
     }
     // If ext/intl is not loaded, return a dummy translator
     if (!extension_loaded('intl')) {
         return new MvcTranslator(new DummyTranslator());
     }
     // Load a translator from configuration, if possible
     if ($serviceLocator->has('Config')) {
         $config = $serviceLocator->get('Config');
         // 'translator' => false
         if (array_key_exists('translator', $config) && $config['translator'] === false) {
             return new MvcTranslator(new DummyTranslator());
         }
         // 'translator' => array( ... translator options ... )
         if (array_key_exists('translator', $config) && (is_array($config['translator']) && !empty($config['translator']) || $config['translator'] instanceof Traversable)) {
             $i18nTranslator = Translator::factory($config['translator']);
             $serviceLocator->setService('Zend\\I18n\\Translator\\TranslatorInterface', $i18nTranslator);
             return new MvcTranslator($i18nTranslator);
         }
     }
     // For BC purposes (pre-2.3.0), use the I18n Translator
     return new MvcTranslator(new Translator());
 }
开发者ID:JeoffScott,项目名称:dyplom,代码行数:32,代码来源:TranslatorServiceFactory.php

示例6: setUp

 /**
  * Set up service manager and database configuration.
  *
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     $sManagerConfig = new Config(['abstract_factories' => ['SphinxSearch\\Db\\Adapter\\AdapterAbstractServiceFactory']]);
     $this->serviceManager = new ServiceManager();
     $sManagerConfig->configureServiceManager($this->serviceManager);
     $this->serviceManager->setService('Config', ['sphinxql' => ['adapters' => ['SphinxSearch\\Db\\Adapter\\One' => ['driver' => 'pdo_mysql'], 'SphinxSearch\\Db\\Adapter\\Two' => ['driver' => 'pdo_mysql']]]]);
 }
开发者ID:ripaclub,项目名称:sphinxsearch,代码行数:12,代码来源:AdapterAbstractServiceFactoryTest.php

示例7: setServiceLocator

 public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
 {
     $this->services = $serviceLocator;
     // adding cache service
     if (!$this->services->has('cache')) {
         $cache = new \BaseXMS\Cache\Storage\Adapter\Filesystem();
         $cache->setOptions(array('cache_dir' => 'data/cache'));
         $this->services->setService('cache', $cache);
     }
 }
开发者ID:pkamps,项目名称:basexms,代码行数:10,代码来源:UiComposer.php

示例8: setUp

 /**
  * Set up LoggerAbstractServiceFactory and loggers configuration.
  *
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(array('abstract_factories' => array('Zend\\Log\\LoggerAbstractServiceFactory'))));
     $this->serviceManager->setService('Config', array('log' => array('Application\\Frontend' => array(), 'Application\\Backend' => array())));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:10,代码来源:LoggerAbstractServiceFactoryTest.php

示例9: setUp

 /**
  * Set up service manager and database configuration.
  *
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(array('abstract_factories' => array('Zend\\Db\\Adapter\\AdapterAbstractServiceFactory'))));
     $this->serviceManager->setService('Config', array('db' => array('adapters' => array('Zend\\Db\\Adapter\\Writer' => array('driver' => 'mysqli'), 'Zend\\Db\\Adapter\\Reader' => array('driver' => 'mysqli')))));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:10,代码来源:AdapterAbstractServiceFactoryTest.php

示例10: setUp

 /**
  * Set up service manager and database configuration.
  *
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     $this->serviceManager = new ServiceManager(new Config(array('factories' => array('SphinxSearch\\Db\\Adapter\\Adapter' => 'SphinxSearch\\Db\\Adapter\\AdapterServiceFactory'), 'alias' => array('sphinxql' => 'SphinxSearch\\Db\\Adapter\\Adapter'))));
     $this->serviceManager->setService('Config', array('sphinxql' => array('driver' => 'pdo_mysql')));
 }
开发者ID:joacub,项目名称:sphinxsearch,代码行数:10,代码来源:AdapterServiceFactoryTest.php

示例11: setUp

 /**
  * Set up service manager and database configuration.
  *
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     $this->serviceManager = new ServiceManager(new Config(array('abstract_factories' => array('SphinxSearch\\Db\\Adapter\\AdapterAbstractServiceFactory'))));
     $this->serviceManager->setService('Config', array('sphinxql' => array('adapters' => array('SphinxSearch\\Db\\Adapter\\One' => array('driver' => 'pdo_mysql'), 'SphinxSearch\\Db\\Adapter\\Two' => array('driver' => 'pdo_mysql')))));
 }
开发者ID:joacub,项目名称:sphinxsearch,代码行数:10,代码来源:AdapterAbstractServiceFactoryTest.php


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