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
Move name inflection into routing. #8091
Conversation
This moves inflection into a more 'correct' place, but causes a bunch of other issues like breaking route symmetry between parse() and url(). I feel like the Controller location is less troublesome as the routing layer cares very little about the casing whereas the controller cares about its name being properly inflected. Refs #8085
Isn't using a lowercase controller name in the router always an error? We could just not inflect it, and at the controller actors level throw an exception or at least trigger an error. I think this is in the top list of problems in cake, one we try to correct with hi sort of code but that often breaks applications in case sensitive file systems |
The routing layer doesn't care about the the casing of the controller names, outside of the casing being consistent between parsing/matching which is something that would break with this change. Previously the following would work: Router::connect('/:controller/:action/*');
$url = '/articles/view/1';
$this->assertSame($url, Router::url(Router::parse($url))); That would no longer be the case after this change, and that is the kind of breakage I'm worried about. You are right though that controller construction and usage requires a CamelCase controller name. |
i agree that it is bad to break the symmetry in the router. That is why I suggested triggering an error in the controller factory dispatcher, having to use the inflector is a clear indicator of a user mistake |
Reading the original issue #8081 again I see that the problem occurred due to using lower cased controller name |
Hmm throwing an exception at router level might not be feasible since child classes could inflecte the URL parts parsed by |
Since we are striving to reduce inflections I think this camelization of plugin name in controller factory should also be removed. |
The route matched because
I can get behind that. I'll make another pull request. |
Controller names that are not CamelCase cause a few issues downstream: 1. They don't work on case-sensitive filesystems. 2. They cause Controller::$name and Controller::$modelClass to be wrong. To help reduce these cryptic and environment sensitive issues we reject all controller names that start with a lower case letter. Refs #8091 Refs #8085
This moves inflection into a more 'correct' place, but causes a bunch of other issues like breaking route symmetry between parse() and url().
I feel like the Controller location is less troublesome as the routing layer cares very little about the casing whereas the controller cares about its name being properly inflected.
Refs #8085