This commit is contained in:
xl
2024-08-29 12:00:10 +08:00
parent 6efd221585
commit 1795b59b88
4 changed files with 37 additions and 25 deletions
+12 -6
View File
@@ -58,6 +58,12 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
protected array $httpHandler = [];
/**
* @var array<string, object>
*/
protected array $controllers = [];
/**
* @var Handler
*/
@@ -137,11 +143,11 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
{
try {
$route = $this->_splicing_routing($route);
if ($closure instanceof Closure) {
$handler = $this->interpreter->addRouteByClosure($closure);
} else {
$handler = $this->resolve($closure, $this->interpreter);
}
// if ($closure instanceof Closure) {
// $handler = $this->interpreter->addRouteByClosure($closure);
// } else {
// }
$handler = $this->resolve($closure, $this->interpreter);
foreach ($method as $value) {
if ($value instanceof RequestMethod) {
$value = $value->getString();
@@ -169,7 +175,7 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
foreach ($this->methods as $methodPath => $handler) {
[$path, $method] = explode('_', $methodPath);
$controller = $handler->isClosure() ? '\Closure' : $handler->getClass() . '::' . $handler->getMethod();
$controller = $handler instanceof Closure ? '\Closure' : $handler->getClass() . '::' . $handler->getMethod();
$array[] = [
'path' => $path,
'method' => $method,