Skip to content

Commit

Permalink
fix: Auto Routing (Improved) Default Method Fallback does not work wi…
Browse files Browse the repository at this point in the history
…th $translateUriToCamelCase
  • Loading branch information
kenjis committed Jun 21, 2024
1 parent 29e5fab commit ea5a585
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion system/Router/AutoRouterImproved.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,15 @@ private function checkUriForMethod(string $method): void
return;
}

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.
if (
method_exists($this->controller, $method)
// We do not permit `controller/somemethod`, so check the exact method
// name.
&& ! in_array($method, get_class_methods($this->controller), true)
) {
throw new PageNotFoundException(
'"' . $this->controller . '::' . $method . '()" is not found.'
);
Expand Down

0 comments on commit ea5a585

Please sign in to comment.