This commit is contained in:
2021-09-24 18:39:46 +08:00
parent b153ea4aaa
commit e5efe8eb84
2 changed files with 15 additions and 6 deletions
+9 -3
View File
@@ -56,10 +56,16 @@ class MiddlewareManager extends BaseObject
*/
public static function get($handler): mixed
{
if ($handler instanceof Closure || !isset(static::$_middlewares[$handler[0]])) {
return null;
if (!($handler instanceof Closure)) {
if (!isset(static::$_middlewares[$handler[0]])) {
static::$_middlewares[$handler[0]] = [];
}
if (!isset(static::$_middlewares[$handler[0]][$handler[1]])) {
static::$_middlewares[$handler[0]][$handler[1]] = new Iterator();
}
return static::$_middlewares[$handler[0]][$handler[1]];
}
return static::$_middlewares[$handler[0]][$handler[1]] ?? null;
return new Iterator();
}