protected function getSerializer()
 {
     $injector = new Injector();
     $serializer = new RESTfulAPI_BasicSerializer();
     $injector->inject($serializer);
     return $serializer;
 }
 protected function getQueryHandler()
 {
     $injector = new Injector();
     $qh = new RESTfulAPI_DefaultQueryHandler();
     $injector->inject($qh);
     return $qh;
 }
 protected function getAuthenticator()
 {
     $injector = new Injector();
     $auth = new RESTfulAPI_TokenAuthenticator();
     $injector->inject($auth);
     return $auth;
 }
 /**
  * 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);
 }
 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
0
 /**
  * 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
0
 /**
  * @expectedException UndefinedResourceException
  */
 public function testInvalidResourceAlias()
 {
     $toInject = new \InvalidNameInjectable();
     $injector = new Injector($this->getContext());
     $injector->inject($toInject);
 }