Feature #459
Implement dependency injection via abstract factory methods
Status: | Closed | Start date: | 2008-04-16 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Robert Lemke | % Done: | 0% |
|
Category: | Object | |||
Target version: | - | Estimated time: | 0.00 hour | |
PHP Version: | Complexity: | |||
Has patch: |
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.
History
#1 Updated by Robert Lemke about 7 years ago
- Target version deleted (
45)
#2 Updated by Robert Lemke about 7 years ago
- Status changed from Accepted to Closed
- Estimated time set to 0.00
Dropped the idea for now (see mailing list discussion about component factory).