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 @@ -647,7 +647,21 @@ automatically! You can simplify the controller to::
647647 }
648648
649649That'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
You can’t perform that action at this time.
0 commit comments