改名
This commit is contained in:
+29
-10
@@ -49,16 +49,25 @@ class Router extends Application implements RouterInterface
|
|||||||
if (!isset($this->nodes[$method])) {
|
if (!isset($this->nodes[$method])) {
|
||||||
$this->nodes[$method] = [];
|
$this->nodes[$method] = [];
|
||||||
}
|
}
|
||||||
list($first, $explode) = $this->split($path);
|
// list($first, $explode) = $this->split($path);
|
||||||
$parent = $this->nodes[$method][$first] ?? null;
|
|
||||||
if (empty($parent)) {
|
$paths = array_column($this->groupTacks, 'prefix');
|
||||||
$parent = $this->NodeInstance($first, 0, $method);
|
$path = implode('/', $paths) . '/' . ltrim($path, '/');
|
||||||
$this->nodes[$method][$first] = $parent;
|
|
||||||
}
|
|
||||||
if ($first !== '/') {
|
// $parent = $this->nodes[$method][$first] ?? null;
|
||||||
$parent = $this->bindNode($parent, $explode, $method);
|
|
||||||
}
|
$this->nodes[$method][$path] = $this->NodeInstance($path, 0, $method);
|
||||||
return $parent->bindHandler($handler);
|
|
||||||
|
|
||||||
|
// if (empty($parent)) {
|
||||||
|
// $parent = $this->NodeInstance($first, 0, $method);
|
||||||
|
// $this->nodes[$method][$first] = $parent;
|
||||||
|
// }
|
||||||
|
// if ($first !== '/') {
|
||||||
|
// $parent = $this->bindNode($parent, $explode, $method);
|
||||||
|
// }
|
||||||
|
return $this->nodes[$method][$path]->bindHandler($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -411,6 +420,16 @@ class Router extends Application implements RouterInterface
|
|||||||
*/
|
*/
|
||||||
private function find_path($request)
|
private function find_path($request)
|
||||||
{
|
{
|
||||||
|
$method = $request->getMethod();
|
||||||
|
if (!isset($this->nodes[$method])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$methods = $this->nodes[$method];
|
||||||
|
$uri = implode('/', $request->getExplode());
|
||||||
|
if (!isset($methods[$uri])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $this->nodes[$method][$uri];
|
||||||
$node = $this->tree_search($request->getExplode(), $request->getMethod());
|
$node = $this->tree_search($request->getExplode(), $request->getMethod());
|
||||||
if ($node instanceof Node) {
|
if ($node instanceof Node) {
|
||||||
return $node;
|
return $node;
|
||||||
|
|||||||
Reference in New Issue
Block a user