From 5cc5e6a1f73b8647ffe0a6b53e1844425a5b1cee Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Fri, 21 May 2021 16:35:26 +0200 Subject: [PATCH] Fix missing dependency. --- .../ClosingMotiveRepository.php | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php index c99ca8efc..5c1525b52 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php @@ -27,46 +27,41 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\ResultSetMappingBuilder; -/** - * Class ClosingMotiveRepository - * Entity repository for closing motives - * - * @package Chill\PersonBundle\Repository - */ final class ClosingMotiveRepository { private EntityRepository $repository; + private EntityManagerInterface $entityManager; + public function __construct(EntityManagerInterface $entityManager) { + $this->entityManager = $entityManager; $this->repository = $entityManager->getRepository(ClosingMotive::class); } /** - * @param bool $onlyLeaf * @return mixed */ public function getActiveClosingMotive(bool $onlyLeaf = true) { - $rsm = new ResultSetMappingBuilder($this->repository->getEntityManager()); + $rsm = new ResultSetMappingBuilder($this->entityManager); $rsm->addRootEntityFromClassMetadata($this->repository->getClassName(), 'cm'); - $sql = "SELECT ".(string) $rsm." + $sql = "SELECT " . (string) $rsm . " FROM chill_person_accompanying_period_closingmotive AS cm WHERE active IS TRUE "; - + if ($onlyLeaf) { $sql .= "AND cm.id NOT IN ( SELECT DISTINCT parent_id FROM chill_person_accompanying_period_closingmotive WHERE parent_id IS NOT NULL )"; } - + $sql .= " ORDER BY cm.ordering ASC"; return $this - ->repository - ->getEntityManager() + ->entityManager ->createNativeQuery($sql, $rsm) ->getResult(); }