From 7c03a25f1a8fb37cdddf1986bb0271af23fd5b52 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 20 Jun 2024 17:28:19 +0200 Subject: [PATCH] Refactor AccompanyingCourseDocumentRepository.php Build where clause using StoredObject directly instead\ of based on it's id. --- .../Repository/AccompanyingCourseDocumentRepository.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php index 239b88b90..93cf00ecb 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php @@ -46,12 +46,11 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository return $qb->getQuery()->getSingleScalarResult(); } - public function findLinkedCourseDocument(int $storedObjectId): ?AccompanyingCourseDocument { + public function findLinkedCourseDocument(StoredObject $storedObject): ?AccompanyingCourseDocument { $qb = $this->repository->createQueryBuilder('d'); - $query = $qb->leftJoin('d.storedObject', 'do') - ->where('do.id = :storedObjectId') - ->setParameter('storedObjectId', $storedObjectId) + $query = $qb->where('d.storedObject = :storedObject') + ->setParameter('storedObject', $storedObject) ->getQuery(); return $query->getResult();