diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php index 54672c6b7..4d621d56e 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php @@ -17,6 +17,8 @@ use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\NoResultException; use Doctrine\Persistence\ManagerRegistry; /** @@ -100,6 +102,10 @@ class ActivityRepository extends ServiceEntityRepository implements AssociatedEn return $qb->getQuery()->getResult(); } + /** + * @throws NonUniqueResultException + * @throws NoResultException + */ public function findAssociatedEntityToStoredObject(StoredObject $storedObject): ?object { $qb = $this->createQueryBuilder('a'); @@ -110,6 +116,6 @@ class ActivityRepository extends ServiceEntityRepository implements AssociatedEn ->setParameter('storedObjectId', $storedObject->getId()) ->getQuery(); - return $query->getResult(); + return $query->getSingleResult(); } } diff --git a/src/Bundle/ChillEventBundle/Repository/EventRepository.php b/src/Bundle/ChillEventBundle/Repository/EventRepository.php index 24eb095ec..b720866f2 100644 --- a/src/Bundle/ChillEventBundle/Repository/EventRepository.php +++ b/src/Bundle/ChillEventBundle/Repository/EventRepository.php @@ -16,6 +16,8 @@ use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\EventBundle\Entity\Event; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\NoResultException; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; @@ -36,6 +38,10 @@ class EventRepository implements ObjectRepository, AssociatedEntityToStoredObjec return $this->repository->createQueryBuilder($alias, $indexBy); } + /** + * @throws NonUniqueResultException + * @throws NoResultException + */ public function findAssociatedEntityToStoredObject(StoredObject $storedObject): ?object { $qb = $this->createQueryBuilder('e'); @@ -46,7 +52,7 @@ class EventRepository implements ObjectRepository, AssociatedEntityToStoredObjec ->setParameter('storedObjectId', $storedObject->getId()) ->getQuery(); - return $query->getResult(); + return $query->getSingleResult(); } public function find($id)