File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -650,7 +650,21 @@ automatically! You can simplify the controller to::
650
650
}
651
651
652
652
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
+ }
654
668
655
669
.. tip ::
656
670
You can’t perform that action at this time.
0 commit comments