Add recursive route inclusion

This commit is contained in:
Alma Armas 2021-01-18 17:04:04 +00:00
parent 9a14e22d89
commit a43eda027b
1 changed files with 5 additions and 1 deletions

View File

@ -237,11 +237,15 @@ class Router
function readRoutes(string $filename, string $namespace, bool $autoprefix = true): void
{
$config = yaml_parse_file($filename);
$config = chandler_parse_yaml($filename);
if(isset($config["static"]))
$this->pushStatic($namespace, CHANDLER_EXTENSIONS_ENABLED . "/$namespace/Web/$config[static]");
if(isset($config["include"]))
foreach($config["include"] as $include)
$this->readRoutes(dirname($filename) . "/$include", $namespace, $autoprefix);
foreach($config["routes"] as $route) {
$route = (object) $route;
$placeholders = $route->placeholders ?? [];