I’d like to inject a class in a child class, but not in the parent. How can I correct my code :
abstract class ParentAbstract {
/** @var RegistryInterface */
protected $doctrine;
/** @var EntityManager */
protected $entityManager;
public function __construct(RegistryInterface $doctrine) {
$this->doctrine = $doctrine;
$this->entityManager = $doctrine->getManager();
}
...
}
final class Child extends ParentAbstract {
/** @var KernelInterface */
protected $kernel;
public function __construct(KernelInterface $kernel) {
$this->kernel = $kernel;
}
}
Even when I call the parent constructor it won’t work ! What should I do ?
Source: Symfony4 Questions
Was this helpful?
0 / 0