Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ebd793a2d3 | |||
| ec370baa45 | |||
| aca9694723 |
@@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -309,16 +309,16 @@ final class request
|
|||||||
*/
|
*/
|
||||||
public bool $smartphone {
|
public bool $smartphone {
|
||||||
// Read
|
// Read
|
||||||
get() {
|
get {
|
||||||
if (!isset($this->{__PROPERTY__})) {
|
if (!isset($this->smartphone)) {
|
||||||
// The property is not initialized
|
// The property is not initialized
|
||||||
|
|
||||||
// Writing into the property
|
// Writing into the property
|
||||||
$this->{__PROPERTY__} = new mobile()->isMobile();
|
$this->smartphone = new mobile()->isMobile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return $this->{__PROPERTY__};
|
return $this->smartphone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,16 +331,16 @@ final class request
|
|||||||
*/
|
*/
|
||||||
public bool $tablet {
|
public bool $tablet {
|
||||||
// Read
|
// Read
|
||||||
get() {
|
get {
|
||||||
if (!isset($this->{__PROPERTY__})) {
|
if (!isset($this->tablet)) {
|
||||||
// The property is not initialized
|
// The property is not initialized
|
||||||
|
|
||||||
// Writing into the property
|
// Writing into the property
|
||||||
$this->{__PROPERTY__} = new mobile()->isTablet();
|
$this->tablet = new mobile()->isTablet();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return $this->{__PROPERTY__};
|
return $this->tablet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,17 +162,30 @@ final class router
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finding a priority route from match results
|
if (array_all($matches, fn($value) => $value === false)) {
|
||||||
|
// Not found any route
|
||||||
|
|
||||||
|
if (false) {
|
||||||
|
// Initialized the errors controller
|
||||||
|
|
||||||
|
// Processing the `404` error method
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Found At least one route
|
||||||
|
|
||||||
|
// Finding a priority route from all match results (setting the $route variable)
|
||||||
foreach ($matches as $route => $match) if ($match !== false) break;
|
foreach ($matches as $route => $match) if ($match !== false) break;
|
||||||
|
unset($match);
|
||||||
|
|
||||||
if ($route && !empty($data = $this->routes[$route])) {
|
if ($route && !empty($data = $this->routes[$route])) {
|
||||||
// Route found
|
// The route found
|
||||||
|
|
||||||
// Universalization of route
|
// Universalization of the route
|
||||||
$route = self::universalize($route);
|
$route = self::universalize($route);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization of route variables
|
* Initialization of the route variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
foreach ($routes[$route] as $i => $route_directory) {
|
foreach ($routes[$route] as $i => $route_directory) {
|
||||||
@@ -180,7 +194,7 @@ final class router
|
|||||||
if (preg_match('/^\$([a-zA-Z_\x80-\xff]+)$/', $route_directory) === 1) {
|
if (preg_match('/^\$([a-zA-Z_\x80-\xff]+)$/', $route_directory) === 1) {
|
||||||
// The directory is a variable ($variable)
|
// The directory is a variable ($variable)
|
||||||
|
|
||||||
// Запись в реестр переменных и перещапись директории в маршруте
|
// Запись в реестр переменных и перезапись директории в маршруте
|
||||||
$data[$request->method->value]->variables[trim($route_directory, '$')] = $directories[$i];
|
$data[$request->method->value]->variables[trim($route_directory, '$')] = $directories[$i];
|
||||||
} else if (preg_match('/^\$([a-zA-Z_\x80-\xff]+\.\.\.)$/', $route_directory) === 1) {
|
} else if (preg_match('/^\$([a-zA-Z_\x80-\xff]+\.\.\.)$/', $route_directory) === 1) {
|
||||||
// The directory of route is a collector ($variable...)
|
// The directory of route is a collector ($variable...)
|
||||||
@@ -209,8 +223,9 @@ final class router
|
|||||||
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