改名
This commit is contained in:
@@ -11,7 +11,6 @@ use Exception;
|
|||||||
use HttpServer\Abstracts\HttpService;
|
use HttpServer\Abstracts\HttpService;
|
||||||
use HttpServer\Http\Request;
|
use HttpServer\Http\Request;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use ReflectionClass;
|
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Snowflake\Aop;
|
use Snowflake\Aop;
|
||||||
use Snowflake\Core\Json;
|
use Snowflake\Core\Json;
|
||||||
@@ -85,11 +84,7 @@ class Node extends HttpService
|
|||||||
public function bindHandler($handler): static
|
public function bindHandler($handler): static
|
||||||
{
|
{
|
||||||
if (is_string($handler) && str_contains($handler, '@')) {
|
if (is_string($handler) && str_contains($handler, '@')) {
|
||||||
list($controller, $action) = explode('@', $handler);
|
$this->handler = $this->splitHandler($handler);
|
||||||
if (!class_exists($controller) && !empty($this->namespace)) {
|
|
||||||
$controller = implode('\\', $this->namespace) . '\\' . $controller;
|
|
||||||
}
|
|
||||||
$this->handler = [Snowflake::getDi()->get($controller), $action];
|
|
||||||
} else if ($handler != null && !is_callable($handler, true)) {
|
} else if ($handler != null && !is_callable($handler, true)) {
|
||||||
$this->_error = 'Controller is con\'t exec.';
|
$this->_error = 'Controller is con\'t exec.';
|
||||||
} else {
|
} else {
|
||||||
@@ -100,6 +95,22 @@ class Node extends HttpService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $handler
|
||||||
|
* @return array
|
||||||
|
* @throws NotFindClassException
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
private function splitHandler(string $handler): array
|
||||||
|
{
|
||||||
|
list($controller, $action) = explode('@', $handler);
|
||||||
|
if (!class_exists($controller) && !empty($this->namespace)) {
|
||||||
|
$controller = implode('\\', $this->namespace) . '\\' . $controller;
|
||||||
|
}
|
||||||
|
return [Snowflake::getDi()->get($controller), $action];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws NotFindClassException
|
* @throws NotFindClassException
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
|
|||||||
Reference in New Issue
Block a user