getInstance() 공개 메소드

public getInstance ( $className, $name = '' )
예제 #1
0
 public function __construct($name = null, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     $this->injectorConfig = new InjectorConfig();
     $this->frontControllerBindings($this->injectorConfig);
     $injector = new Injector($this->injectorConfig);
     $this->frontController = $injector->getInstance('\\Ouzo\\FrontController');
 }
예제 #2
0
 private function getInstance(RouteRule $routeRule, $controller)
 {
     $controllerInstance = $this->injector->getInstance($controller);
     $controllerInstance->initialize($routeRule);
     return $controllerInstance;
 }
예제 #3
0
 /**
  * @test
  */
 public function shouldModifyConfigAfterCreation()
 {
     //given
     $object = new ClassWithNoDep();
     $config = new InjectorConfig();
     $injector = new Injector($config);
     $config->bind('\\ClassWithNoDep')->toInstance($object);
     //ControllerTestCase exposes injectorConfig and allows users to add their bindings after injector is created
     //when
     $instance = $injector->getInstance('\\ClassWithNoDep');
     //then
     $this->assertSame($object, $instance);
 }