core arguments null, router 404 error controller
This commit is contained in:
@@ -272,7 +272,7 @@ final class core
|
|||||||
// Arguments not match the controller method arguments
|
// Arguments not match the controller method arguments
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return (string) $route->controller->{$route->method}($arguments);
|
return (string) $route->controller->{$route->method}($arguments ? $arguments : null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ final class router
|
|||||||
// Skipping unmatched routes based on results of previous iterations
|
// Skipping unmatched routes based on results of previous iterations
|
||||||
if (isset($matches[$route]) && $matches[$route] === false) continue;
|
if (isset($matches[$route]) && $matches[$route] === false) continue;
|
||||||
|
|
||||||
|
|
||||||
// Initializing of route directory
|
// Initializing of route directory
|
||||||
$route_directory = $routes[$route][$i] ?? null;
|
$route_directory = $routes[$route][$i] ?? null;
|
||||||
|
|
||||||
@@ -161,56 +162,70 @@ final class router
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finding a priority route from match results
|
if (array_all($matches, fn($value) => $value === false)) {
|
||||||
foreach ($matches as $route => $match) if ($match !== false) break;
|
// Not found any route
|
||||||
|
|
||||||
if ($route && !empty($data = $this->routes[$route])) {
|
if (false) {
|
||||||
// Route found
|
// Initialized the errors controller
|
||||||
|
|
||||||
// Universalization of route
|
// Processing the `404` error method
|
||||||
$route = self::universalize($route);
|
|
||||||
|
|
||||||
/**
|
}
|
||||||
* Initialization of route variables
|
} else {
|
||||||
*/
|
// Found At least one route
|
||||||
|
|
||||||
foreach ($routes[$route] as $i => $route_directory) {
|
// Finding a priority route from all match results (setting the $route variable)
|
||||||
// Iteration over directories of route
|
foreach ($matches as $route => $match) if ($match !== false) break;
|
||||||
|
unset($match);
|
||||||
|
|
||||||
if (preg_match('/^\$([a-zA-Z_\x80-\xff]+)$/', $route_directory) === 1) {
|
if ($route && !empty($data = $this->routes[$route])) {
|
||||||
// The directory is a variable ($variable)
|
// The route found
|
||||||
|
|
||||||
// Запись в реестр переменных и перещапись директории в маршруте
|
// Universalization of the route
|
||||||
$data[$request->method->value]->variables[trim($route_directory, '$')] = $directories[$i];
|
$route = self::universalize($route);
|
||||||
} else if (preg_match('/^\$([a-zA-Z_\x80-\xff]+\.\.\.)$/', $route_directory) === 1) {
|
|
||||||
// The directory of route is a collector ($variable...)
|
|
||||||
|
|
||||||
// Инициализаия ссылки на массив сборщика
|
/**
|
||||||
$collector = &$data[$request->method->value]->variables[trim($route_directory, '$.')];
|
* Initialization of the route variables
|
||||||
|
*/
|
||||||
|
|
||||||
// Инициализаия массива сборщика
|
foreach ($routes[$route] as $i => $route_directory) {
|
||||||
$collector ??= [];
|
// Iteration over directories of route
|
||||||
|
|
||||||
// Запись в реестр переменных
|
if (preg_match('/^\$([a-zA-Z_\x80-\xff]+)$/', $route_directory) === 1) {
|
||||||
$collector[] = $directories[$i];
|
// The directory is a variable ($variable)
|
||||||
|
|
||||||
foreach (array_slice($directories, ++$i, preserve_keys: true) as &$urn_directory) {
|
// Запись в реестр переменных и перезапись директории в маршруте
|
||||||
// Перебор директорий URN
|
$data[$request->method->value]->variables[trim($route_directory, '$')] = $directories[$i];
|
||||||
|
} else if (preg_match('/^\$([a-zA-Z_\x80-\xff]+\.\.\.)$/', $route_directory) === 1) {
|
||||||
|
// The directory of route is a collector ($variable...)
|
||||||
|
|
||||||
|
// Инициализаия ссылки на массив сборщика
|
||||||
|
$collector = &$data[$request->method->value]->variables[trim($route_directory, '$.')];
|
||||||
|
|
||||||
|
// Инициализаия массива сборщика
|
||||||
|
$collector ??= [];
|
||||||
|
|
||||||
// Запись в реестр переменных
|
// Запись в реестр переменных
|
||||||
$collector[] = $urn_directory;
|
$collector[] = $directories[$i];
|
||||||
|
|
||||||
|
foreach (array_slice($directories, ++$i, preserve_keys: true) as &$urn_directory) {
|
||||||
|
// Перебор директорий URN
|
||||||
|
|
||||||
|
// Запись в реестр переменных
|
||||||
|
$collector[] = $urn_directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Exit (success or fail)
|
// Exit (success or fail)
|
||||||
return $data[$request->method->value] ?? null;
|
return $data[$request->method->value] ?? null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit (fail)
|
// Exit (success/fail)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user