middleware)) { $this->middleware = [$this->middleware]; } $array = []; foreach ($this->middleware as $value) { $sn = di($value); if (!($sn instanceof IMiddleware)) { continue; } $array[] = [$sn, 'onHandler']; } $this->middleware = $array; } /** * @param mixed $class * @param mixed|null $method * @return $this * @throws ReflectionException * @throws NotFindClassException */ public function execute(mixed $class, mixed $method = null): static { $middleware = Kiri::getDi()->get(MiddlewareManager::class); $middleware->addMiddlewares($class, $method, $this->middleware); return $this; } }