本文整理匯總了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;
}
示例3: getAuthenticator
protected function getAuthenticator()
{
$injector = new Injector();
$auth = new RESTfulAPI_TokenAuthenticator();
$injector->inject($auth);
return $auth;
}
示例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);
}
示例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));
}
示例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));
}
}
}
示例7: testInvalidResourceAlias
/**
* @expectedException UndefinedResourceException
*/
public function testInvalidResourceAlias()
{
$toInject = new \InvalidNameInjectable();
$injector = new Injector($this->getContext());
$injector->inject($toInject);
}