G
G
gitdev2018-12-12 14:52:30
symfony
gitdev, 2018-12-12 14:52:30

Do I need to move the call to the repositories into services?

From the point of view of DDD, should getting data from repositories be in services or in controllers?

$counterResidential = $this->getDoctrine()
            ->getRepository('AppBundle:Realty')
            ->countByType([Type::TYPES['flat'], Type::TYPES['home']]);

        $counterCommercial = $this->getDoctrine()
            ->getRepository('AppBundle:Realty')
            ->countByType([Type::TYPES['commercial']]);

        $realties = $realtyService->getOnStatus([Status::STATUSES['premium'], Status::STATUSES['top']]);

        $about = $this
            ->getDoctrine()
            ->getRepository('AppBundle:About')
            ->findOneBy([]);

        $reviews = $this
            ->getDoctrine()
            ->getRepository('AppBundle:AgentReview')
            ->findBy(['is_showing' => true], null, 2, 0);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2018-12-12
@sidni

In services, but if I were you, I would inject repositories in the service constructor and not get them from the container (manager)
PS Well, according to DDD, you need to make your own repository interface, on the basis of which to make your own repositories, and not use it directly with the original Doctrine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question