Feature #459

Implement dependency injection via abstract factory methods

Added by Robert Lemke over 11 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Object
Target version:
-
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.

History

#1 Updated by Robert Lemke over 11 years ago

  • Target version deleted (45)

#2 Updated by Robert Lemke over 11 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).

Also available in: Atom PDF