改名
This commit is contained in:
@@ -13,7 +13,6 @@ use HttpServer\IInterface\RouterInterface;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use ReflectionException;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Core\Json;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
@@ -469,65 +468,11 @@ class Router extends HttpService implements RouterInterface
|
||||
$paths = [];
|
||||
foreach ($this->nodes as $node) {
|
||||
/** @var Node[] $node */
|
||||
foreach ($node as $_node) {
|
||||
// if ($_node->path == '/') {
|
||||
// continue;
|
||||
// }
|
||||
$path = strtoupper($_node->method) . ' : ' . $_node->path;
|
||||
if (!empty($_node->childes)) {
|
||||
$path = $this->readByChild($_node->childes, $path);
|
||||
}
|
||||
$paths[] = $path;
|
||||
foreach ($node as $path => $_node) {
|
||||
$paths[] = strtoupper($_node->method) . ' : ' . $path;
|
||||
}
|
||||
}
|
||||
return $this->readByArray($paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $array
|
||||
* @param array $returns
|
||||
* @return array
|
||||
*/
|
||||
private function readByArray($array, $returns = []): array
|
||||
{
|
||||
foreach ($array as $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
$returns = $this->readByArray($value, $returns);
|
||||
} else {
|
||||
[$method, $route] = explode(' : ', $value);
|
||||
|
||||
$returns[] = ['method' => $method, 'route' => $route];
|
||||
}
|
||||
}
|
||||
return $returns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $child
|
||||
* @param string $paths
|
||||
* @return array
|
||||
*/
|
||||
private function readByChild($child, $paths = ''): array
|
||||
{
|
||||
$newPath = [];
|
||||
/** @var Node $item */
|
||||
foreach ($child as $item) {
|
||||
// if ($item->path == '/') {
|
||||
// continue;
|
||||
// }
|
||||
if (!empty($item->childes)) {
|
||||
$newPath[] = $this->readByChild($item->childes, $paths . '/' . $item->path);
|
||||
} else {
|
||||
[$first, $route] = explode(' : ', $paths);
|
||||
|
||||
$newPath[] = strtoupper($item->method) . ' : ' . $route . '/' . $item->path;
|
||||
}
|
||||
}
|
||||
return $newPath;
|
||||
return $paths;
|
||||
}
|
||||
|
||||
|
||||
@@ -566,10 +511,6 @@ class Router extends HttpService implements RouterInterface
|
||||
*/
|
||||
public function find_path(Request $request): ?Node
|
||||
{
|
||||
// if ($this->useTree === ROUTER_TREE) {
|
||||
// return $this->Branch_search($request);
|
||||
// }
|
||||
|
||||
$method = $request->getMethod();
|
||||
$uri = $request->headers->get('request_uri', '/');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user