File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,38 @@ Symfony ships with the following value resolvers in the
2424 Attempts to resolve a backed enum case from a route path parameter that matches the name of the argument.
2525 Leads to a 404 Not Found response if the value isn't a valid backing value for the enum type.
2626
27+ For example, if your backed enum is::
28+
29+ namespace App\Model;
30+
31+ enum Suit: string
32+ {
33+ case Hearts = 'H';
34+ case Diamonds = 'D';
35+ case Clubs = 'C';
36+ case Spades = 'S';
37+ }
38+
39+ And your controller contains the following:
40+
41+ class CardController
42+ {
43+ #[Route('/cards/{suit}')]
44+ public function list(Suit $suit): Response
45+ {
46+ // ...
47+ }
48+
49+ // ...
50+ }
51+
52+ When requesting the ``/cards/H `` URL, the ``$suit `` variable will store the
53+ ``Suit::Hearts `` case.
54+
55+ .. versionadded :: 6.1
56+
57+ The ``BackedEnumValueResolver `` was introduced in Symfony 6.1.
58+
2759:class: `Symfony\\ Component\\ HttpKernel\\ Controller\\ ArgumentResolver\\ RequestAttributeValueResolver `
2860 Attempts to find a request attribute that matches the name of the argument.
2961
You can’t perform that action at this time.
0 commit comments