当前位置: 首页>>代码示例>>PHP>>正文


PHP Horde_Injector::createChildInjector方法代码示例

本文整理汇总了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);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:22,代码来源:Closure.php

示例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);
 }
开发者ID:horde,项目名称:horde,代码行数:24,代码来源:Factory.php

示例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'));
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:10,代码来源:InjectorTest.php


注:本文中的Horde_Injector::createChildInjector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。