Skip to content

Commit d04ddec

Browse files
committed
Merge branch '6.4' into 7.2
* 6.4: [Doctrine] Show nullable arguments in EntityValueResolver
2 parents f3c8163 + 5cda87c commit d04ddec

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
@@ -647,7 +647,21 @@ automatically! You can simplify the controller to::
647647
}
648648

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

652666
.. tip::
653667

0 commit comments

Comments
 (0)