Fix repositories to fetch entity linked to stored object

getSingleResult() replaced by getOneOrNullResult() to\ avoid error being thrown.
Fix naming of properties.
This commit is contained in:
2024-07-02 12:48:18 +02:00
parent 5b0babb9b0
commit 064dfc5a56
6 changed files with 11 additions and 23 deletions

View File

@@ -102,20 +102,15 @@ class ActivityRepository extends ServiceEntityRepository implements AssociatedEn
return $qb->getQuery()->getResult();
}
/**
* @throws NonUniqueResultException
* @throws NoResultException
*/
public function findAssociatedEntityToStoredObject(StoredObject $storedObject): ?Activity
{
$qb = $this->createQueryBuilder('a');
$query = $qb
->join('a.documents', 'ad')
->join('ad.storedObject', 'so')
->where('so.id = :storedObjectId')
->leftJoin('a.documents', 'ad')
->where('ad.id = :storedObjectId')
->setParameter('storedObjectId', $storedObject->getId())
->getQuery();
return $query->getSingleResult();
return $query->getOneOrNullResult();
}
}