當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Injector::load方法代碼示例

本文整理匯總了PHP中Injector::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP Injector::load方法的具體用法?PHP Injector::load怎麽用?PHP Injector::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Injector的用法示例。


在下文中一共展示了Injector::load方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCustomObjectCreator

 public function testCustomObjectCreator()
 {
     $injector = new Injector();
     $injector->setObjectCreator(new SSObjectCreator());
     $config = array('OriginalRequirementsBackend', 'DummyRequirements' => array('class' => 'DummyRequirements(\'%$OriginalRequirementsBackend\')'));
     $injector->load($config);
     $requirements = $injector->get('DummyRequirements');
     $this->assertEquals('OriginalRequirementsBackend', get_class($requirements->backend));
 }
開發者ID:normann,項目名稱:sapphire,代碼行數:9,代碼來源:InjectorTest.php

示例2: testTooManyArrayValues

 /**
  * @expectedException InvalidArgumentException
  */
 public function testTooManyArrayValues()
 {
     $injector = new Injector();
     $config = array('TestService' => array('class' => 'TestObject', 'calls' => array(array('method', array('args'), 'what is this?'))));
     $injector->load($config);
     $item = $injector->get('TestService');
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:10,代碼來源:InjectorTest.php

示例3: testConvertServicePropertyOnCreate

 public function testConvertServicePropertyOnCreate()
 {
     // make sure convert service property is not called on direct calls to create, only on configured
     // declarations to avoid un-needed function calls
     $injector = new Injector();
     $item = $injector->create('ConstructableObject', '%$TestObject');
     $this->assertEquals('%$TestObject', $item->property);
     // do it again but have test object configured as a constructor dependency
     $injector = new Injector();
     $config = array('ConstructableObject' => array('constructor' => array('%$TestObject')));
     $injector->load($config);
     $item = $injector->get('ConstructableObject');
     $this->assertTrue($item->property instanceof TestObject);
     // and with a configured object defining TestObject to be something else!
     $injector = new Injector(array('locator' => 'InjectorTestConfigLocator'));
     $config = array('ConstructableObject' => array('constructor' => array('%$TestObject')));
     $injector->load($config);
     $item = $injector->get('ConstructableObject');
     $this->assertTrue($item->property instanceof ConstructableObject);
     $this->assertInstanceOf('OtherTestObject', $item->property->property);
 }
開發者ID:aaronleslie,項目名稱:aaronunix,代碼行數:21,代碼來源:InjectorTest.php


注:本文中的Injector::load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。