File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1245,6 +1245,35 @@ A possible solution is to change the parameter requirements to be more permissiv
12451245 as the token and the format will be empty. This can be solved by replacing
12461246 the ``.+ `` requirement by ``[^.]+ `` to allow any character except dots.
12471247
1248+ Backed Enum as Parameter
1249+ ~~~~~~~~~~~~~~~~~~~~~~~~
1250+
1251+ PHP 8.1 add support for Backed Enum, they can be used as route parameter and
1252+ automatically converted to their value by Symfony.
1253+
1254+ .. versionadded :: 6.3
1255+
1256+ Using a `\BackedEnum ` as route parameter is available since Symfony 6.3.
1257+
1258+ .. code-block :: php-attributes
1259+
1260+ // src/Controller/DefaultController.php
1261+ namespace App\Controller;
1262+
1263+ use App\Enum\SuitsEnum;
1264+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1265+ use Symfony\Component\HttpFoundation\Response;
1266+ use Symfony\Component\Routing\Annotation\Route;
1267+
1268+ class DefaultController extends AbstractController
1269+ {
1270+ #[Route('/cards/{suit}', name: 'cards_suit')]
1271+ public function list(SuitsEnum $suit = SuitsEnum::Diamonds): Response
1272+ {
1273+ // ...
1274+ }
1275+ }
1276+
12481277 .. _routing-alias :
12491278
12501279Route Aliasing
You can’t perform that action at this time.
0 commit comments