-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Add FQCN and FQCN::method aliases when applicable #50084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Symfony/Component/Routing/Tests/Fixtures/AnnotationFixtures/InvokableMethodController.php
Show resolved
Hide resolved
src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableMethodController.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice :)
What about deprecating the name generated by getDefaultRouteName (when it exists) and always adding an alias named FQCN::method
(or just FQCN when method is __invoke
)
6f19dad
to
ce17164
Compare
} | ||
} | ||
|
||
if ($fqcnAlias && 1 === $collection->count()) { | ||
$collection->addAlias($class->name, $invokeRouteName = key($collection->all())); | ||
$collection->addAlias(sprintf('%s::__invoke', $class->name), $invokeRouteName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means we add an "FQCN::__invoke" alias for controllers like this:
#[Route(path: '/foo')]
final class FooController
{
public function __invoke():
{
}
}
This does not seem to deprecate the default name though AFAICT |
@stof Indeed, I don't think it's worth it to deprecate the default name and Nicolas agreed after discussing it with him on Slack. |
ce17164
to
9fa5bae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the PR description for 6.4 and give some example use cases
Thank you @fancyweb. |
See #49981, I think it's a great idea 😃
__invoke
method that adds a route AND if the target class added 1 route exactly.