-
-
Notifications
You must be signed in to change notification settings - Fork 0
DeferMiddleware
github-actions edited this page Mar 26, 2026
·
1 revision
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.
- Full name:
\FastForward\Defer\Middleware\DeferMiddleware - This class is marked as final and can't be subclassed
- This class implements:
MiddlewareInterface - This class is a Final class
Constructs a new DeferMiddleware instance.
public __construct(string $attribute = \FastForward\Defer\DeferInterface::class): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$attribute |
string | the attribute name to use for storing the Defer instance (optional) |
Returns the attribute name used to store the Defer instance.
public getAttribute(): stringReturn Value:
the attribute name
Retrieves the Defer instance from the request.
public getDefer(\Psr\Http\Message\ServerRequestInterface $request): \FastForward\Defer\DeferInterfaceThis method MUST throw a LogicException if the Defer instance is not found.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$request |
\Psr\Http\Message\ServerRequestInterface | the request to retrieve the Defer instance from |
Return Value:
the Defer instance
Throws:
Processes the request, injecting the Defer instance and ensuring execution at the end.
public process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler): \Psr\Http\Message\ResponseInterfaceParameters:
| Parameter | Type | Description |
|---|---|---|
$request |
\Psr\Http\Message\ServerRequestInterface | the incoming request |
$handler |
\Psr\Http\Server\RequestHandlerInterface | the request handler |
Return Value:
the response from the handler