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