Feature #459
Implement dependency injection via abstract factory methods
Start date:
2008-04-16
Due date:
% Done:
0%
Estimated time:
0.00 h
PHP Version:
Has patch:
Complexity:
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.
Updated by Robert Lemke almost 14 years ago
- Status changed from Accepted to Closed
- Estimated time set to 0.00 h
Dropped the idea for now (see mailing list discussion about component factory).