qqq
This commit is contained in:
+18
-11
@@ -40,6 +40,21 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
|
|||||||
private array $methods = [];
|
private array $methods = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Handler
|
||||||
|
*/
|
||||||
|
protected Handler $found;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->found = new Handler([di(NotFoundController::class), 'fail'], []);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -187,19 +202,11 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
|
|||||||
/**
|
/**
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param string $method
|
* @param string $method
|
||||||
* @return Handler|null
|
* @return Handler
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
public function query(string $path, string $method): ?Handler
|
public function query(string $path, string $method): Handler
|
||||||
{
|
{
|
||||||
if ($method === 'OPTIONS') {
|
return $this->methods[$method . '_' . $path] ?? $this->found;
|
||||||
$path = '/*';
|
|
||||||
}
|
|
||||||
$parent = $this->methods[$method . '_' . $path] ?? null;
|
|
||||||
if ($parent === null) {
|
|
||||||
return new Handler([di(NotFoundController::class), 'fail'], []);
|
|
||||||
}
|
|
||||||
return $parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user