-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: [Auto Routing Improved] Default Method Fallback does not work with $translateUriToCamelCase
#8980
fix: [Auto Routing Improved] Default Method Fallback does not work with $translateUriToCamelCase
#8980
Conversation
0d96fba
to
ea5a585
Compare
system/Router/AutoRouterImproved.php
Outdated
if (! in_array($method, get_class_methods($this->controller), true)) { | ||
// If `getSomeMethod()` exists, only `controller/some-method` should be | ||
// accessible. But if a visitor navigates to `controller/somemethod`, | ||
// `getSomemethod()` will be checked, and method_exists() will return true. |
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.
// `getSomemethod()` will be checked, and method_exists() will return true. | |
// `getSomeMethod()` will be checked, and method_exists() will return true. |
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.
Auto Routing Improved tries to convert a URI to a controller class/method.
If controller/somemethod
comes, it will try to check Controller::getSomemethod()
(not Controller::getSomeMethod()
). Because it adds prefix get
and camelizes the URI segment for method.
And in this exaple, there is only Controller::getSomeMethod()
, but method_exists()
returns true
because method names in PHP are case-insensitive.
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.
Improved the comment. d474187
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.
Thank you for the explanation.
794c0e3
to
497b499
Compare
73dd2e7
to
d474187
Compare
Description
$translateUriToCamelCase
Navigate to
http://localhost:8080/product/15/edit
.Before:
After:
Checklist: