Skip to content

[symfony] Relax RequireRouteNameToGenerateControllerRouteRule for Symfony 6.4+ FQCN routes - #332

Closed
TomasVotruba wants to merge 1 commit into
mainfrom
relax-route-name-generate-rule
Closed

TomasVotruba wants to merge 1 commit into
mainfrom
relax-route-name-generate-rule

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes #326

Since Symfony 6.4, the FQCN route alias is auto-created for any invokable controller that has a #[Route], regardless of its name - see https://symfony.com/blog/new-in-symfony-6-4-fqcn-based-routes

So requiring #[Route(name: self::class)] above __invoke() produced false positives: $router->generate(SomeController::class) resolves fine as long as the controller has any route.

This relaxes the rule to only fire when the __invoke() controller has no #[Route] at all (or has no __invoke()), which is the case where generate() genuinely cannot resolve.

  • updated error message and README
  • test now asserts an arbitrary route name is accepted; the no-route source fixture is genuinely route-less

…pt any #[Route] on __invoke()

Since Symfony 6.4 the FQCN route alias is auto-created for any route name,
so requiring #[Route(name: self::class)] produced false positives. Only fire
when the __invoke() controller has no #[Route] at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make "RequireRouteNameToGenerateControllerRouteRule" optional

1 participant