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 0d96fba
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions system/Router/AutoRouterImproved.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,17 @@ private function checkUriForMethod(string $method): void
return;
}

if (! in_array($method, get_class_methods($this->controller), true)) {
throw new PageNotFoundException(
'"' . $this->controller . '::' . $method . '()" is not found.'
);
// 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.
if (! in_array($method, get_class_methods($this->controller), true)) {
throw new PageNotFoundException(
'"' . $this->controller . '::' . $method . '()" is not found.'
);
}
}
}

Expand Down

0 comments on commit 0d96fba

Please sign in to comment.