-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Routing] [WIP] New override property in Route attribute #60197
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
|
Hey! To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
|
Why are you exposing the the issue is that your class actually looks like that right now at runtime (with an unknown order of functions as I don't know how PHP orders functions copied from traits): class PostController
{
#[Route('/add', name: 'add', methods: ['GET', 'POST'])]
public function add(Request $request, TranslatorInterface $trans)
{
// Custom logic for creating a new post entity
// This will override the method from the CrudTrait
}
#[Route('/add', name: 'add', methods: ['GET', 'POST'])]
public function crudAdd(Request $request)
{
// ... Logic to create a new entity
}
}And so you have 2 routes with the same name defined in that class. |
|
On second thought, I think you'd be better off rethinking the architecture of your code rather than complicating the framework to meet your needs. We already have a You can move some of the Or go the other way if the controller signature doesn't need to be modified: from |
|
Thanks all for your comments |
It could be useful to add 'override' property into Route attribute. In this example, I need to override 'add' function but by default, the trait's route replace the controller's route.
Maybe
defaultinstead ofoverride?