本文整理汇总了PHP中Zend\ServiceManager\ServiceManager::addPeeringServiceManager方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceManager::addPeeringServiceManager方法的具体用法?PHP ServiceManager::addPeeringServiceManager怎么用?PHP ServiceManager::addPeeringServiceManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\ServiceManager\ServiceManager
的用法示例。
在下文中一共展示了ServiceManager::addPeeringServiceManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanGetAliasedServicesFromPeeringServiceManagers
/**
* @covers Zend\ServiceManager\ServiceManager::setAlias
* @covers Zend\ServiceManager\ServiceManager::get
* @covers Zend\ServiceManager\ServiceManager::retrieveFromPeeringManager
*/
public function testCanGetAliasedServicesFromPeeringServiceManagers()
{
$service = new \stdClass();
$peeringSm = new ServiceManager();
$peeringSm->setService('actual-service-name', $service);
$this->serviceManager->addPeeringServiceManager($peeringSm);
$this->serviceManager->setAlias('alias-name', 'actual-service-name');
$this->assertSame($service, $this->serviceManager->get('alias-name'));
}
示例2: ServiceManager
/**
* @covers Zend\ServiceManager\ServiceManager::setService
* @covers Zend\ServiceManager\ServiceManager::get
* @covers Zend\ServiceManager\ServiceManager::retrieveFromPeeringManagerFirst
* @covers Zend\ServiceManager\ServiceManager::setRetrieveFromPeeringManagerFirst
* @covers Zend\ServiceManager\ServiceManager::addPeeringServiceManager
*/
public function testRetrieveServiceFromPeeringServiceManagerIfretrieveFromPeeringManagerFirstSetToTrueAndServiceNamesAreSame()
{
$foo1 = "foo1";
$boo1 = "boo1";
$boo2 = "boo2";
$this->serviceManager->setService($foo1, $boo1);
$this->assertEquals($this->serviceManager->get($foo1), $boo1);
$serviceManagerChild = new ServiceManager();
$serviceManagerChild->setService($foo1, $boo2);
$this->assertEquals($serviceManagerChild->get($foo1), $boo2);
$this->assertFalse($this->serviceManager->retrieveFromPeeringManagerFirst());
$this->serviceManager->setRetrieveFromPeeringManagerFirst(true);
$this->assertTrue($this->serviceManager->retrieveFromPeeringManagerFirst());
$this->serviceManager->addPeeringServiceManager($serviceManagerChild);
$this->assertContains($serviceManagerChild, $this->readAttribute($this->serviceManager, 'peeringServiceManagers'));
$this->assertEquals($serviceManagerChild->get($foo1), $boo2);
$this->assertEquals($this->serviceManager->get($foo1), $boo2);
}
示例3: testAllowsRetrievingFromPeeringContainerFirst
public function testAllowsRetrievingFromPeeringContainerFirst()
{
$parent = new ServiceManager();
$parent->setFactory('foo', function ($sm) {
return 'bar';
});
$child = new ServiceManager();
$child->setFactory('foo', function ($sm) {
return 'baz';
});
$child->addPeeringServiceManager($parent, ServiceManager::SCOPE_PARENT);
$child->setRetrieveFromPeeringManagerFirst(true);
$this->assertEquals('bar', $child->get('foo'));
}