Answer the question
In order to leave comments, you need to log in
Get doctrine container in symfony 4?
tell me how to get an instance of the doctrine class
In all examples they write something like:
$this->getDoctrine()
$this->getContener->get('doctrine');
how to get it without $this ?
What namespace is needed? my class does not inherit a bunch of everything.
Answer the question
In order to leave comments, you need to log in
use Symfony\Bridge\Doctrine\RegistryInterface;
// ...
protected $doctrine;
// ...
public function __construct(RegistryInterface $registry)
{
// доктрина ($registry) в констуктор заинжектится сама
$thits->doctrine = $registry;
}
Can you give an example why you need it? Maybe you don't need a copy of the doctrine?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question