Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing inflections out from the router, this also means that default
routes need to change or be treated differently
- Loading branch information
Showing
7 changed files
with
34 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5a0a796
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.
After this, if in routes.php you have
controller=>'pages'
instead ofcontroller=>'Pages'
the message is "Error: PagesController could not be found" with instructions to "Create the class PagesController below in file: App/Controller/PagesController.php". But obviously the file is there and the error message can prove quite misleading :)5a0a796
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.
Yeah the error message isn't ideal. The exception class is inflecting the routing param which is going to be misleading, I can remove the un-necessary inflection in the error message.
5a0a796
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.
If I read you right, that means the suggestion would then be to create a pagesController instead. This could lead to more confusion IMO.
5a0a796
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.
So add a google style "Did you mean ...."? :)
5a0a796
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.
If I follow correctly, this exception will fire if
I think it's simpler to add a check for a lowercase controller name and display an appropriate message, which will catch number 2 above. This way inflection can be removed from calls of type
$this->redirect(['controller'=>'test'])
(if not removed already).5a0a796
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.
@spiliot That is not what I meant at all about creating a
pagesController
that doesn't follow any conventions that CakePHP has. I meant that the error page is incorrect and should handle situations where developers make mistakes defining their routes.A 404 - which missing controller error is - will be thrown in the situations you described, however the redirect() and url() calls should be caught and converted into exceptions before a URL is generated. This work is not yet complete, but I'm planning on starting it very soon, along with other changes to Router/routing.
5a0a796
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.
Excellent! Thanks