变更
This commit is contained in:
@@ -26,6 +26,41 @@ class Middleware
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $method
|
||||
* @param string $middleware
|
||||
* @param array $construct
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function set(string $className, string $method, string $middleware, array $construct = []): void
|
||||
{
|
||||
$path = $className . '::' . $method;
|
||||
if ($this->map->has($path)) {
|
||||
$values = $this->map->get($path);
|
||||
if (in_array($middleware, $values)) {
|
||||
return;
|
||||
}
|
||||
if (!in_array(MiddlewareInterface::class, class_implements($middleware))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->map->append($path, [$middleware, $construct]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $method
|
||||
* @return array
|
||||
*/
|
||||
public function get(string $className, string $method): array
|
||||
{
|
||||
return $this->routeMap->get($className . '::' . $method) ?? [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $middleware
|
||||
|
||||
Reference in New Issue
Block a user