本文整理汇总了PHP中Horde_Injector::addBinder方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Injector::addBinder方法的具体用法?PHP Horde_Injector::addBinder怎么用?PHP Horde_Injector::addBinder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Injector
的用法示例。
在下文中一共展示了Horde_Injector::addBinder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
* @link http://pear.horde.org/index.php?package=Injector
*/
class Binder implements Horde_Injector_Binder
{
/**
* Create an instance.
*
* @param Horde_Injector $injector The injector should provide all required
* dependencies for creating the instance.
*
* @return mixed The concrete instance.
*/
public function create(Horde_Injector $injector)
{
return 'constructed';
}
/**
* Determine if one binder equals another binder
*
* @param Horde_Injector_Binder $binder The binder to compare against $this
*
* @return bool true if they are equal, or false if they are not equal
*/
public function equals(Horde_Injector_Binder $binder)
{
return false;
}
}
$a = new Horde_Injector(new Horde_Injector_TopLevel());
$a->addBinder('constructed', new Binder());
var_dump($a->getInstance('constructed'));
示例2: 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'));
}