Answer the question
In order to leave comments, you need to log in
Symfony 3, one service, multiple repositories, how to write in services.yml?
Please help, there is a service, this service has several tables in db, more specifically 7.
Each of these tables has its own entity and its own repository.
In the service, there are simple requests in the functions that I would like to organize through the repository, such as findAll()
But, if I access the repository in the service like this (for example):
$a = $this->em->getRepository('AppBundle :RepoOne')->findAll();
$b = $this->em->getRepository('AppBundle:RepoTwo')->findAll();
$c = $this->em->getRepository('AppBundle:RepoThree')->findAll();
It swears that the repository is not registered for the service in services.yml
It should be written something like this:
myservice:
class: AppBundle\Services\Myservice
arguments: [ "@doctrine", "@configure", "@kernel"]
myservice.repository:
class: AppBundle\Repository\MyServiceRepository
arguments: [ "@doctrine.dbal.default_connection"]
namespace AppBundle\Repository;
use AppBundle\Entity\RepoOne;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question