Commit a569d34
committed
minor #16363 [HttpKernel] Add a controller argument resolver for backed enums (ogizanagi)
This PR was merged into the 6.1 branch.
Discussion
----------
[HttpKernel] Add a controller argument resolver for backed enums
Fixes #16357
Adding a ref to the `BackedEnumValueResolver` introduced in 6.1 to https://symfony.com/doc/current/controller/argument_value_resolver.html
Added before `RequestAttributeValueResolver` since it has a higher priority.
Don't know however where we could showcase such an example:
Given:
```php
namespace App\Model;
enum Suit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
```
and the controller:
```php
class CardController
{
#[Route('/cards/{suit}')]
public function list(Suit $suit): Response
{
// [...]
}
}
```
A request to `/cards/H` would inject the `Suit::Hearts` enum case into the controller `$suit` argument.
Commits
-------
12f72b6 [HttpKernel] Add a controller argument resolver for backed enums1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| |||
0 commit comments