Skip to content

Commit d72818d

Browse files
committed
minor symfony#10698 Less code (MohamedElKadaoui)
This PR was submitted for the 3.4 branch but it was merged into the 2.8 branch instead (closes symfony#10698). Discussion ---------- Less code <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 8e6b9f6 Less code
2 parents afb1a60 + 8e6b9f6 commit d72818d

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

doctrine/associations.rst

+1-5
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,7 @@ following method to the ``ProductRepository`` class::
375375
WHERE p.id = :id'
376376
)->setParameter('id', $productId);
377377

378-
try {
379-
return $query->getSingleResult();
380-
} catch (\Doctrine\ORM\NoResultException $exception) {
381-
return null;
382-
}
378+
return $query->getOneOrNullResult();
383379
}
384380

385381
Now, you can use this method in your controller to query for a ``Product``

0 commit comments

Comments
 (0)