Changeset 856
- Timestamp:
- 08/20/07 22:29:41 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/experiments/people/schst/ioc/provider.php
r855 r856 22 22 23 23 public function get(stubReflectionClass $type) { 24 if ($type->getName() === 'Person Impl') {24 if ($type->getName() === 'Person') { 25 25 return new PersonImpl('Stephan'); 26 26 } trunk/src/main/php/net/stubbles/ioc/stubClassBinding.php
r855 r856 183 183 */ 184 184 public function create() { 185 if ($this->provider === null) {186 $this->provider = new stubDefaultInjectionProvider($this->injector);187 }188 185 if (is_string($this->impl)) { 189 186 $this->impl = new stubReflectionClass($this->impl); 190 187 } 191 return $this->provider->get($this->impl); 188 if ($this->provider === null) { 189 $this->provider = new stubDefaultInjectionProvider($this->injector, $this->impl); 190 } 191 return $this->provider->get(new stubReflectionClass($this->type)); 192 192 } 193 193 trunk/src/main/php/net/stubbles/ioc/stubDefaultInjectionProvider.php
r855 r856 30 30 31 31 /** 32 * The concrete implementation to use 33 * 34 * @var stubReflectionClass 35 */ 36 protected $impl; 37 38 /** 32 39 * Create a new provider 33 40 * 34 41 * @param stubInjector $injector 35 42 */ 36 public function __construct(stubInjector $injector ) {43 public function __construct(stubInjector $injector, stubReflectionClass $impl) { 37 44 $this->injector = $injector; 45 $this->impl = $impl; 38 46 } 39 47 … … 45 53 */ 46 54 public function get(stubReflectionClass $type) { 47 48 if (is_string($type)) { 49 $type = new stubReflectionClass($type); 50 } 51 52 $constructor = $type->getConstructor(); 55 $constructor = $this->impl->getConstructor(); 53 56 if ($constructor === null) { 54 $instance = $t ype->newInstance();57 $instance = $this->impl->newInstance(); 55 58 } elseif (!$constructor->hasAnnotation('Inject')) { 56 $instance = $t ype->newInstance();59 $instance = $this->impl->newInstance(); 57 60 } else { 58 61 $paramValues = array(); … … 61 64 $paramValues[] = $this->injector->getInstance($class->getName()); 62 65 } 63 $instance = $t ype->newInstanceArgs($paramValues);66 $instance = $this->impl->newInstanceArgs($paramValues); 64 67 } 65 68 66 foreach ($t ype->getMethods() as $method) {69 foreach ($this->impl->getMethods() as $method) { 67 70 if (strncmp($method->getName(), '__', 2) === 0) { 68 71 continue;
