S
S
symnoob2019-07-09 21:47:14
symfony
symnoob, 2019-07-09 21:47:14

Symfony 4 How to use one Entity with multiple Repositories?

Hello everyone,
How to use one Entity with multiple Repositories?
thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kafkiansky, 2019-07-09
@symnoob

class TestRepository1
{
    /**
     * @var ObjectRepository
     */
    private $repository;

    /**
     * @var EntityManagerInterface
     */
    private $em;
    public function __construct(EntityManagerInterface $em)
    {
        $this->repository = $em->getRepository(Test::class);
        $this->em = $em;
    }
}

class TestRepository2
{
    /**
     * @var ObjectRepository
     */
    private $repository;

    /**
     * @var EntityManagerInterface
     */
    private $em;
    public function __construct(EntityManagerInterface $em)
    {
        $this->repository = $em->getRepository(Test::class);
        $this->em = $em;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question