0 follower

Final Class Yiisoft\PsrEmitter\EmitterMiddleware

InheritanceYiisoft\PsrEmitter\EmitterMiddleware
ImplementsPsr\Http\Server\MiddlewareInterface

EmitterMiddleware is a middleware that sends the response to the client using implementation of EmitterInterface.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\PsrEmitter\EmitterInterface $emitter = new SapiEmitter() )
$emitter Yiisoft\PsrEmitter\EmitterInterface

Emitter to send the response.

                public function __construct(
    private readonly EmitterInterface $emitter = new SapiEmitter(),
) {
}

            
process() public method

public \Psr\Http\Message\ResponseInterface process ( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler )
$request \Psr\Http\Message\ServerRequestInterface
$handler \Psr\Http\Server\RequestHandlerInterface
throws Yiisoft\PsrEmitter\HeadersHaveBeenSentException

If headers have already been sent.

                public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
    $response = $handler->handle($request);
    $this->emitter->emit($response);
    return $response;
}