You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 enums
0 commit comments