本文整理汇总了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);
}
示例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'));
}
示例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']);
}
示例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;
}
示例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);
}