Skip to content

Commit 5cda87c

Browse files
committed
minor #21044 [Doctrine] Show nullable arguments in EntityValueResolver (javiereguiluz)
This PR was merged into the 6.4 branch. Discussion ---------- [Doctrine] Show nullable arguments in `EntityValueResolver` Fixes #20618. Commits ------- bb6be95 [Doctrine] Show nullable arguments in EntityValueResolver
2 parents aa9df3b + bb6be95 commit 5cda87c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

doctrine.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,21 @@ automatically! You can simplify the controller to::
650650
}
651651

652652
That's it! The attribute uses the ``{id}`` from the route to query for the ``Product``
653-
by the ``id`` column. If it's not found, a 404 page is generated.
653+
by the ``id`` column. If it's not found, a 404 error is thrown.
654+
655+
You can change this behavior by making the controller argument optional. In that
656+
case, no 404 is thrown automatically and you're free to handle the missing entity
657+
yourself::
658+
659+
#[Route('/product/{id}')]
660+
public function show(?Product $product): Response
661+
{
662+
if (null === $product) {
663+
// run your own logic to return a custom response
664+
}
665+
666+
// ...
667+
}
654668

655669
.. tip::
656670

0 commit comments

Comments
 (0)