- Fixed route generating (removed methods)

This commit is contained in:
Dave M. 2024-11-21 19:15:04 -05:00
parent b24bbbc150
commit 830a643a56
1 changed files with 6 additions and 4 deletions

View File

@ -160,13 +160,15 @@ PATTERN;
$this->eventExecute(UrlRegisterRouteEvent::class, $name, $array); $this->eventExecute(UrlRegisterRouteEvent::class, $name, $array);
} }
protected function findRoute(string $name, string $method = "GET") : false|array protected function findRoute(string $name, string $method = "*") : false|array
{ {
foreach($this->routes as $route) { foreach($this->routes as $route) {
if ( ($route['name'] === $name) && in_array(strtoupper($method), $route['routeMethods']) ) { if ( $route['name'] === $name ) {
if ($method === '*' || in_array(strtoupper($method), $route['routeMethods']) ) {
return $route; return $route;
} }
} }
}
return false; return false;
} }
@ -287,7 +289,7 @@ PATTERN;
if ($default ?? false) { if ($default ?? false) {
$value = $default; $value = $default;
} }
elseif ( ! str_contains($route, "[{$matches[0][0]}]") && ! str_contains($route, "[/{$matches[0][0]}]") && $this->enforceExistingArguments) { elseif ( $this->enforceExistingArguments && ! preg_match(sprintf("/\[\/?%s]/i", $item[0]), $route) ) {
throw new \RuntimeException(sprintf("Error while preparing route %s : could not match variable '%s' into given arguments ( %s ) from %s::%s", $route, $variable, json_encode($arguments), $routeParam['class'], $routeParam['classMethod'])); throw new \RuntimeException(sprintf("Error while preparing route %s : could not match variable '%s' into given arguments ( %s ) from %s::%s", $route, $variable, json_encode($arguments), $routeParam['class'], $routeParam['classMethod']));
} }
} }