diff --git a/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReader.php b/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReader.php index 4e15b2226a53..2aeb91c6aa0d 100644 --- a/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReader.php +++ b/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReader.php @@ -65,8 +65,9 @@ public function read(string $class, string $defaultController = 'Home', string $ // Remove HTTP verb prefix. $methodInUri = lcfirst(substr($methodName, strlen($httpVerb))); + // Check if it is the default method. if ($methodInUri === $defaultMethod) { - $routeWithoutController = $this->getRouteWithoutController( + $routeForDefaultController = $this->getRouteForDefaultController( $classShortname, $defaultController, $classInUri, @@ -75,8 +76,11 @@ public function read(string $class, string $defaultController = 'Home', string $ $httpVerb ); - if ($routeWithoutController !== []) { - $output = [...$output, ...$routeWithoutController]; + if ($routeForDefaultController !== []) { + // The controller is the default controller. It only + // has a route for the default method. Other methods + // will be routed even if they exist. + $output = [...$output, ...$routeForDefaultController]; continue; } @@ -93,7 +97,7 @@ public function read(string $class, string $defaultController = 'Home', string $ continue; } - // Skip the default controller. + // If it is the default controller, no more routes exists. if ($classShortname === $defaultController) { continue; } @@ -156,9 +160,9 @@ private function getUriByClass(string $classname): string } /** - * Gets a route without default controller. + * Gets a route for the default controller. */ - private function getRouteWithoutController( + private function getRouteForDefaultController( string $classShortname, string $defaultController, string $uriByClass,