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


PHP Injector::inject方法代碼示例

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


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

示例1: getSerializer

 protected function getSerializer()
 {
     $injector = new Injector();
     $serializer = new RESTfulAPI_BasicSerializer();
     $injector->inject($serializer);
     return $serializer;
 }
開發者ID:helpfulrobot,項目名稱:colymba-silverstripe-restfulapi,代碼行數:7,代碼來源:RESTfulAPI_BasicSerializer_Test.php

示例2: getQueryHandler

 protected function getQueryHandler()
 {
     $injector = new Injector();
     $qh = new RESTfulAPI_DefaultQueryHandler();
     $injector->inject($qh);
     return $qh;
 }
開發者ID:8secs,項目名稱:cocina,代碼行數:7,代碼來源:RESTfulAPI_DefaultQueryHandler_Test.php

示例3: getAuthenticator

 protected function getAuthenticator()
 {
     $injector = new Injector();
     $auth = new RESTfulAPI_TokenAuthenticator();
     $injector->inject($auth);
     return $auth;
 }
開發者ID:colymba,項目名稱:silverstripe-restfulapi,代碼行數:7,代碼來源:RESTfulAPI_TokenAuthenticator_Test.php

示例4: loadContext

 /**
  * Load the application context
  * @return ApplicationContext
  */
 protected function loadContext($config)
 {
     $loader = ContextLoaderFactory::getLoader($config);
     $context = $loader->load($config);
     $injector = new Injector($context);
     foreach ($context->getResources() as $resource) {
         $injector->inject($resource);
     }
     foreach ($context->getResources() as $resource) {
         if ($resource instanceof InitializingBean) {
             $resource->afterPropertiesSet();
         }
     }
     PiconApplication::get()->getContextLoadListener()->onContextLoaded($context);
 }
開發者ID:picon,項目名稱:picon-framework,代碼行數:19,代碼來源:ContextApplicationInitializer.php

示例5: testOverridePriority

 public function testOverridePriority()
 {
     $injector = new Injector();
     $injector->setAutoScanProperties(true);
     $config = array(array('src' => TEST_SERVICES . '/SampleService.php', 'priority' => 10));
     // load
     $injector->load($config);
     // inject
     $myObject = new TestObject();
     $injector->inject($myObject);
     $this->assertEquals(get_class($myObject->sampleService), 'SampleService');
     $config = array(array('src' => TEST_SERVICES . '/AnotherService.php', 'id' => 'SampleService', 'priority' => 1));
     // load
     $injector->load($config);
     $injector->inject($myObject);
     $this->assertEquals('SampleService', get_class($myObject->sampleService));
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:17,代碼來源:InjectorTest.php

示例6: load_models

 /**
  * Injects model names into ActiveRecordBase by using the ModelInjector.
  */
 private function load_models()
 {
     if (!is_array($this->models)) {
         $this->models = explode(',', $this->models);
     }
     foreach ($this->models as $model) {
         if (trim($model) != '') {
             $this->injector->inject('model', trim($model));
         }
     }
 }
開發者ID:BackupTheBerlios,項目名稱:medick-svn,代碼行數:14,代碼來源:Base.php

示例7: testInvalidResourceAlias

 /**
  * @expectedException UndefinedResourceException
  */
 public function testInvalidResourceAlias()
 {
     $toInject = new \InvalidNameInjectable();
     $injector = new Injector($this->getContext());
     $injector->inject($toInject);
 }
開發者ID:picon,項目名稱:picon-framework,代碼行數:9,代碼來源:InjectionTest.php


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