Skip to content

Commit 502a33e

Browse files
committed
feat: parameter info for default controller
1 parent ef1c0e3 commit 502a33e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReader.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public function read(string $class, string $defaultController = 'Home', string $
7373
$classInUri,
7474
$classname,
7575
$methodName,
76-
$httpVerb
76+
$httpVerb,
77+
$method
7778
);
7879

7980
if ($routeForDefaultController !== []) {
@@ -180,7 +181,8 @@ private function getRouteForDefaultController(
180181
string $uriByClass,
181182
string $classname,
182183
string $methodName,
183-
string $httpVerb
184+
string $httpVerb,
185+
ReflectionMethod $method
184186
): array {
185187
$output = [];
186188

@@ -189,12 +191,18 @@ private function getRouteForDefaultController(
189191
$routeWithoutController = rtrim(preg_replace($pattern, '', $uriByClass), '/');
190192
$routeWithoutController = $routeWithoutController ?: '/';
191193

194+
[$params, $routeParams] = $this->getParameters($method);
195+
196+
if ($routeWithoutController === '/' && $routeParams !== '') {
197+
$routeWithoutController = '';
198+
}
199+
192200
$output[] = [
193201
'method' => $httpVerb,
194202
'route' => $routeWithoutController,
195-
'route_params' => '',
203+
'route_params' => $routeParams,
196204
'handler' => '\\' . $classname . '::' . $methodName,
197-
'params' => [],
205+
'params' => $params,
198206
];
199207
}
200208

0 commit comments

Comments
 (0)