Fast Forward Deferred Callbacks utility classes

DeferMiddleware
in package
implements MiddlewareInterface

Read onlyYes
FinalYes

This middleware MUST be used to inject and manage a Defer instance in a PSR-15 ServerRequest.

It SHALL ensure that all deferred callbacks are executed at the end of the request lifecycle. The attribute name MAY be customized via the constructor.

Table of Contents

Interfaces

MiddlewareInterface

Properties

$attribute  : string

Methods

__construct()  : mixed
Constructs a new DeferMiddleware instance.
getAttribute()  : string
Returns the attribute name used to store the Defer instance.
getDefer()  : DeferInterface
Retrieves the Defer instance from the request.
process()  : ResponseInterface
Processes the request, injecting the Defer instance and ensuring execution at the end.

Properties

Methods

__construct()

Constructs a new DeferMiddleware instance.

public __construct([string $attribute = DeferInterface::class ]) : mixed
Parameters
$attribute : string = DeferInterface::class

the attribute name to use for storing the Defer instance (optional)

getAttribute()

Returns the attribute name used to store the Defer instance.

public getAttribute() : string
Return values
string

the attribute name

getDefer()

Retrieves the Defer instance from the request.

public getDefer(ServerRequestInterface $request) : DeferInterface

This method MUST throw a LogicException if the Defer instance is not found.

Parameters
$request : ServerRequestInterface

the request to retrieve the Defer instance from

Tags
throws
LogicException
Return values
DeferInterface

the Defer instance

process()

Processes the request, injecting the Defer instance and ensuring execution at the end.

public process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
$request : ServerRequestInterface

the incoming request

$handler : RequestHandlerInterface

the request handler

Return values
ResponseInterface

the response from the handler


        
On this page

Search results