eee
This commit is contained in:
+10
-6
@@ -11,7 +11,10 @@ class Middleware
|
||||
{
|
||||
|
||||
|
||||
public HashMap $map;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $manager = [];
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,7 +22,6 @@ class Middleware
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->map = new HashMap();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,16 +35,18 @@ class Middleware
|
||||
public function set(string $className, string $method, string|object $middleware): void
|
||||
{
|
||||
$path = $className . '::' . $method;
|
||||
if ($this->map->has($path)) {
|
||||
$values = $this->map->get($path);
|
||||
if (isset($this->manager[$path])) {
|
||||
$values = $this->manager[$path];
|
||||
if (in_array($middleware, $values)) {
|
||||
return;
|
||||
}
|
||||
if (!in_array(MiddlewareInterface::class, class_implements($middleware))) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$this->manager[$path] = [];
|
||||
}
|
||||
$this->map->append($path, $middleware);
|
||||
$this->manager[$path][] = $middleware;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +57,7 @@ class Middleware
|
||||
*/
|
||||
public function get(string $className, string $method): array
|
||||
{
|
||||
return $this->map->get($className . '::' . $method) ?? [];
|
||||
return $this->manager[$className . '::' . $method] ?? [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user