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


PHP ServiceManager::createScopedServiceManager方法代码示例

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


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

示例1: testPeeringService

 public function testPeeringService()
 {
     $di = new Di();
     $di->instanceManager()->setParameters('ZendTest\ServiceManager\TestAsset\Bar', array('foo' => array('a')));
     $this->serviceManager->addAbstractFactory(new DiAbstractServiceFactory($di));
     $sm = $this->serviceManager->createScopedServiceManager(ServiceManager::SCOPE_PARENT);
     $sm->setFactory('di', new DiFactory());
     $bar = $sm->get('ZendTest\ServiceManager\TestAsset\Bar', true);
     $this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Bar', $bar);
 }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:10,代码来源:ServiceManagerTest.php

示例2: testCreateScopedServiceManager

 /**
  * @covers Zend\ServiceManager\ServiceManager::createScopedServiceManager
  */
 public function testCreateScopedServiceManager()
 {
     $this->serviceManager->setService('foo', 'bar');
     $scopedServiceManager = $this->serviceManager->createScopedServiceManager();
     $this->assertNotSame($this->serviceManager, $scopedServiceManager);
     $this->assertFalse($scopedServiceManager->has('foo', false));
     $this->assertContains($this->serviceManager, $this->readAttribute($scopedServiceManager, 'peeringServiceManagers'));
     // test child scoped
     $childScopedServiceManager = $this->serviceManager->createScopedServiceManager(ServiceManager::SCOPE_CHILD);
     $this->assertContains($childScopedServiceManager, $this->readAttribute($this->serviceManager, 'peeringServiceManagers'));
 }
开发者ID:rikaix,项目名称:zf2,代码行数:14,代码来源:ServiceManagerTest.php

示例3: setupSearchService

 /**
  * Support method for getServiceManager()
  *
  * @return void
  */
 protected function setupSearchService()
 {
     $smConfig = new \Zend\ServiceManager\Config(['factories' => ['Solr' => 'VuFind\\Search\\Factory\\SolrDefaultBackendFactory', 'SolrAuth' => 'VuFind\\Search\\Factory\\SolrAuthBackendFactory']]);
     $registry = $this->serviceManager->createScopedServiceManager();
     $smConfig->configureServiceManager($registry);
     $bm = new \VuFind\Search\BackendManager($registry);
     $this->serviceManager->setService('VuFind\\Search\\BackendManager', $bm);
     $ss = new \VuFindSearch\Service();
     $this->serviceManager->setService('VuFind\\Search', $ss);
     $fh = new \VuFind\Search\Solr\HierarchicalFacetHelper();
     $this->serviceManager->setService('VuFind\\HierarchicalFacetHelper', $fh);
     $events = $ss->getEventManager();
     $events->attach('resolve', [$bm, 'onResolve']);
 }
开发者ID:grharry,项目名称:vufind,代码行数:19,代码来源:TestCase.php

示例4: getSearchBackendManager

 /**
  * Construct the search backend manager.
  *
  * @param ServiceManager $sm Service manager.
  *
  * @return \VuFind\Search\BackendManager
  */
 public static function getSearchBackendManager(ServiceManager $sm)
 {
     $config = $sm->get('config');
     $smConfig = new \Zend\ServiceManager\Config($config['vufind']['plugin_managers']['search_backend']);
     $registry = $sm->createScopedServiceManager();
     $smConfig->configureServiceManager($registry);
     $manager = new \VuFind\Search\BackendManager($registry);
     return $manager;
 }
开发者ID:mis306lu,项目名称:vufind-archivesspace,代码行数:16,代码来源:Factory.php

示例5: testPeeringServiceFallbackOnCreateFailure

 public function testPeeringServiceFallbackOnCreateFailure()
 {
     $factory = function ($sm) {
         return new TestAsset\Bar();
     };
     $serviceManager = new ServiceManager();
     $serviceManager->setFactory('ZendTest\\ServiceManager\\TestAsset\\Bar', $factory);
     $sm = $serviceManager->createScopedServiceManager(ServiceManager::SCOPE_CHILD);
     $di = new Di();
     $di->instanceManager()->setParameters('ZendTest\\ServiceManager\\TestAsset\\Bar', array('foo' => array('a')));
     $sm->addAbstractFactory(new DiAbstractServiceFactory($di));
     $bar = $serviceManager->get('ZendTest\\ServiceManager\\TestAsset\\Bar');
     $this->assertInstanceOf('ZendTest\\ServiceManager\\TestAsset\\Bar', $bar);
 }
开发者ID:rudrud,项目名称:zf2,代码行数:14,代码来源:ServiceManagerTest.php


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