本文整理汇总了PHP中Horde_Injector::createChildInjector方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Injector::createChildInjector方法的具体用法?PHP Horde_Injector::createChildInjector怎么用?PHP Horde_Injector::createChildInjector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Injector
的用法示例。
在下文中一共展示了Horde_Injector::createChildInjector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create instance using a closure.
*
* If the closure depends on a Horde_Injector we want to limit its scope
* so it cannot change anything that effects any higher-level scope. A
* closure should not have the responsibility of making a higher-level
* scope change.
* To enforce this we create a new child Horde_Injector. When a
* Horde_Injector is requested from a Horde_Injector it will return
* itself. This means that the closure will only ever be able to work on
* the child Horde_Injector we give it now.
*
* @param Horde_Injector $injector Injector object.
*
* @return Horde_Injector
*/
public function create(Horde_Injector $injector)
{
$childInjector = $injector->createChildInjector();
$closure = $this->_closure;
return $closure($childInjector);
}
示例2: create
/**
* Create instance using a factory method
*
* If the factory depends on a Horde_Injector we want to limit its scope
* so it cannot change anything that effects any higher-level scope. A
* factory should not have the responsibility of making a higher-level
* scope change.
* To enforce this we create a new child Horde_Injector. When a
* Horde_Injector is requested from a Horde_Injector it will return
* itself. This means that the factory will only ever be able to work on
* the child Horde_Injector we give it now.
*
* @param Horde_Injector $injector Injector object.
*
* @return Horde_Injector
*/
public function create(Horde_Injector $injector)
{
$childInjector = $injector->createChildInjector();
/* We use getInstance() here because we don't want to have to create
* this factory more than one time to create more objects of this
* type. */
return $childInjector->getInstance($this->_factory)->{$this->_method}($childInjector);
}
示例3: testShouldAllowChildInjectorsAccessToParentInjectorBindings
public function testShouldAllowChildInjectorsAccessToParentInjectorBindings()
{
$mockInjector = $this->getMock('Horde_Injector_TopLevel', array('getBinder'));
$mockInjector->expects($this->any())->method('getBinder')->with('BOUND_INTERFACE')->will($this->returnValue(new Horde_Injector_Binder_Mock()));
$injector = new Horde_Injector($mockInjector);
$binder = new Horde_Injector_Binder_Mock();
$injector->addBinder('BOUND_INTERFACE', $binder);
$childInjector = $injector->createChildInjector();
$this->assertSame($binder, $childInjector->getBinder('BOUND_INTERFACE'));
}