Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] Improved controller class error#11314
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
jskvara commentedJul 5, 2014
| Q | A |
|---|---|
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #11304 |
| License | MIT |
| Doc PR |
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.
I'm mixed on this. Ido like having the route available later - I think this helps a lot. So Ido want that feature. But, it does feel a little weird passing the$route around (especially in the component, where you could follow a completely different standard for where you store your route (e.g. not_route). The_route comes from the Routing component, which you might not be using.
Anyone have any thoughts on this? Is this possible? Or do we need tonot use the route name? It's an odd situation where the component class actually needs to help us a little bit, otherwise we don't have access to what we need in the FrameworkBundle version ofControllerResolver.
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.
Yes, I have a similar problem as it's not much clear what$route actually means. But I'm not sure if there is better solution for providing route name in exception message.
@fabpot Any ideas?
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.
According toFrameworkBundle'scomposer.json, you already requiresymfony/routing component as a dependency. We're fine to use_route here.
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.
@guilhermeblanco But the_route part is in the actualHttpKernel component - wheresymfony/routing is only a "dev" requirement.
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.
@weaverryan but as aFrameworkBundle dependency, you already require bothHttpKernel andRouting. The_route is gonna always exist in this scenario.
It doesn't really matter thatHttpKernel only has a DEV dependency ofRouting, as long as we plan properly to support this. That's why I consider this patch is not ideal, but rather askRequest as argument and follow convention from stricter type to lesser type. It would then turn the support from:
publicfunction parse($controller,$route =null)
To:
publicfunction parse(Request$request,$controller)
Everything would remain the same inHttpKernel, butFrameworkBundle would add desired support from ticket#11304
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.
@stof I'm going to call on you - what do you think about@guilhermeblanco's approach here and the approach in the issue? I want to bump this along, so I'd love your opinion.
stof commentedJul 7, 2014
Passing the route name to the controller resolver does not make sense IMO. It is not part of the responsibility of the controller resolver to know about routes (and the route name is not even used consistently in exception messages in this PR). I would rather display the original and on a side note, the web debug toolbar will already show you the route name if you don't like searching by the original controller string. |
weaverryan commentedJul 10, 2014
Ha, sorry@stof I missed your comment :) - you knew I wanted your thoughts! And +1 for your suggestion. I think it's abetter solution than we have now, and while not as perfect as including the route name, it's quite good and doesn't cause any pain at all. |
guilhermeblanco commentedJul 10, 2014
@weaverryan my suggested approach does not include the Also, we could also benefit from original controller name. If we do that, we could even reduce the API to: publicfunction parse(Request$request) |
weaverryan commentedJul 11, 2014
@guilhermeblanco you're totally right - I was in a rush yesterday morning, thanks for catching me :). Here's what I'm thinking: A) I don't think we should reduce the API to simply B) But of course, I like the idea in general that if we give the To do this, we could have: parse($controller, Request$request) or we could access the $this->kernel->getContainer()->get('request_stack')->getCurrentRequest()->attributes->get('_route'); So we have 3 options: A) B) Keep everything the same, but access the C) Do nothing and don't include the route name in the exception. I'm for (B), but only if people don't hate it (it's ugly to me). Otherwise, I like (C) because (A) would be a slight BC break in both Thanks! |
guilhermeblanco commentedJul 11, 2014
@weaverryan I'm more (A) than (B), but we should use: parse(Request$request,$controller) The reason is due to higher type enforced argument to a lesser one. It also respects the convention adopted by all methods in the class (Request first). The tiny problem I see with (B) is spurious dependency that can't be easily detected. We should always avoid the usage of Container if you have another way (cleaner) to pass objects, which in this case we do. Lastly, |
stof commentedJul 11, 2014
I'm for C. Using the original controller string (i.e. the argument received in B is too ugly IMO. A is out of question as it requires changing the signature of methods, and so is not BC and we would not be able to make it happen before 3.0 (which defeats the point of trying to improve DX now) |
weaverryan commentedJul 11, 2014
Since you guys don't like (B) (I agree) and A is a BC break, then I think we should do C: not include the route name. If you look at#11304, my original suggestion didn't include the route name and it's still a big improvement over the old error message. @jskvara Can you update your PR tonot include the route name in the exception? You did very nice work to include it, but I don't think it's really possible (at least right now). Thanks! |
guilhermeblanco commentedJul 11, 2014
@stof why is (A) out of question? |
stof commentedJul 11, 2014
@guilhermeblanco the fact that it is not tagged as |
jskvara commentedJul 13, 2014
Thank you all for this discussion. I will update this PR and remove the route name from the exception message. |
jskvara commentedJul 22, 2014
I updated this PR. Sorry for delay, I had busy week. I removed route name from ControllerNameParser and this PR changes just the text of error message. |
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.
Can you put the message on one line?
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.
I didn't want to add line longer than 120 characters. But I updated the PR and it is now one line.
fabpot commentedJul 23, 2014
👍 |
romainneutron commentedJul 23, 2014
👍 |
fabpot commentedJul 24, 2014
Thank you@jskvara. |
…vara)This PR was merged into the 2.6-dev branch.Discussion----------[FrameworkBundle] Improved controller class error| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#11304| License | MIT| Doc PR |Commits-------da41eb1 [FrameworkBundle] improved controller name parse error message