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
24
24
Attempts to resolve a backed enum case from a route path parameter that matches the name of the argument.
25
25
Leads to a 404 Not Found response if the value isn't a valid backing value for the enum type.
26
26
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
+
27
59
:class: `Symfony\\ Component\\ HttpKernel\\ Controller\\ ArgumentResolver\\ RequestAttributeValueResolver `
28
60
Attempts to find a request attribute that matches the name of the argument.
29
61
You can’t perform that action at this time.
0 commit comments