I would like to use traits to instanciate my objects with my DIC:
trait TUseContainer {
protected $c;
public function __construct(Container $c) {
$this->c=$c;
}
}
class MyClass {
use TUseContainer;
//Optional
public function __construct(ClassInheritedFromContainer $c){
TUseContainer::__construct($c);
//MyClass __construct stuff
}
}
So my questions are:
All coments are welcome, thanks.
I'll do some tests and post results.
I got some trivial workaround:
trait TUseContainer {
protected $c;
public function __construct(Container $c) {
$this->setContainer($c);
}
protected function setContainer(Container $c){
$this->c=$c;
}
}
class MyClass {
use TUseContainer;
//Optional
public function __construct(ClassInheritedFromContainer $c){
$this->setContainer($c);
//MyClass __construct stuff
}
}
All coments are still welcome