當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。