當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。