0 follower

Final Class Yiisoft\Middleware\Dispatcher\MiddlewareStack

InheritanceYiisoft\Middleware\Dispatcher\MiddlewareStack
ImplementsPsr\Http\Server\RequestHandlerInterface

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Closure[] $middlewares, \Psr\Http\Server\RequestHandlerInterface $fallbackHandler, \Psr\EventDispatcher\EventDispatcherInterface|null $eventDispatcher null )
$middlewares Closure[]

Middlewares.

$fallbackHandler \Psr\Http\Server\RequestHandlerInterface

Fallback handler

$eventDispatcher \Psr\EventDispatcher\EventDispatcherInterface|null

Event dispatcher to use for triggering before/after middleware events.

                public function __construct(
    private readonly array $middlewares,
    private readonly RequestHandlerInterface $fallbackHandler,
    private readonly ?EventDispatcherInterface $eventDispatcher = null
) {
    if ($middlewares === []) {
        throw new RuntimeException('Stack is empty.');
    }
}

            
handle() public method

public \Psr\Http\Message\ResponseInterface handle ( \Psr\Http\Message\ServerRequestInterface $request )
$request \Psr\Http\Message\ServerRequestInterface

                public function handle(ServerRequestInterface $request): ResponseInterface
{
    if ($this->stack === null) {
        $this->build();
    }
    return $this->stack->handle($request);
}