Skip to content

Commit 63677bb

Browse files
committed
feat: show parameters of default method
1 parent a82b4dc commit 63677bb

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,37 @@ public function read(string $class, string $defaultController = 'Home', string $
7676
);
7777

7878
if ($routeWithoutController !== []) {
79+
// Route for the default controller.
7980
$output = [...$output, ...$routeWithoutController];
8081

8182
continue;
8283
}
8384

85+
$params = [];
86+
$routeParams = '';
87+
$refParams = $method->getParameters();
88+
89+
foreach ($refParams as $param) {
90+
$required = true;
91+
if ($param->isOptional()) {
92+
$required = false;
93+
94+
$routeParams .= '[/..]';
95+
} else {
96+
$routeParams .= '/..';
97+
}
98+
99+
// [variable_name => required?]
100+
$params[$param->getName()] = $required;
101+
}
102+
84103
// Route for the default method.
85104
$output[] = [
86105
'method' => $httpVerb,
87106
'route' => $classInUri,
88-
'route_params' => '',
107+
'route_params' => $routeParams,
89108
'handler' => '\\' . $classname . '::' . $methodName,
90-
'params' => [],
109+
'params' => $params,
91110
];
92111

93112
continue;

0 commit comments

Comments
 (0)