Feature #459
Implement dependency injection via abstract factory methods
| Status: | Closed | Start: | 2008-04-16 | |
| Priority: | Should have | Due date: | ||
| Assigned to: | Robert Lemke | % Done: | 0% |
|
| Category: | Component | |||
| Target version: | - | Estimated time: | 0.00 hours | |
Description
Dependency injection works fine so far as long as components in a singleton scope are requested. Protoype components can't be injected as soon as more than one instance is needed or the requesting class / method needs to have control over the constructor arguments (which is very often the case).
Therefore consumer code currently calls $this->componentManager->getComponent('NameOfProtoypeComponent') in order to get a fresh instance.
This can be optimized by moving the instantiation into an (abstract) factory method:
abstract protected function createSomeComponent($argument1, $argument2);
This method should be detected by the component manager and automatically be implemented by creating a proxy class.