This commit is contained in:
as2252258@163.com
2021-09-12 03:52:16 +08:00
parent b91199671a
commit dd71782fcd
+4 -6
View File
@@ -156,15 +156,13 @@ class Router extends HttpService implements RouterInterface
private function getRootNode($root, $method, bool $create = true): array private function getRootNode($root, $method, bool $create = true): array
{ {
[$start, $explode] = $this->path_recombination($root); [$start, $explode] = $this->path_recombination($root);
$parent = $this->nodes[$start] ?? null;
foreach ($this->nodes as $node) { if ($parent instanceof Node) {
if ($node->path == $start) { return [$parent, $explode];
return [$node, $explode];
}
} }
if ($create) { if ($create) {
$parent = $this->NodeInstance($root, 0, $method); $parent = $this->NodeInstance($root, 0, $method);
$this->nodes[] = $parent; $this->nodes[$start] = $parent;
return [$parent, $explode]; return [$parent, $explode];
} }