Skip to content

SlotMiddleware

SlotMiddleware: establishes a SlotStack in request attributes for nested slot/sub-action rendering.

Later stages (DispatchMiddleware or a future SlotDispatcher) can push/pop keys as they perform slot executions.

class SlotMiddleware implements MiddlewareInterface

ImplementsMiddlewareInterface
SourceMiddleware/SlotMiddleware.php
ConstantValueDescription
ATTR'Quiote\\Execution\\SlotStack'

public function __construct(?Context $context = null): mixed

ParameterTypeDescription
$context?Context

Returns mixed

MethodDescription
process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterfaceAttaches a SlotStack to the request so downstream code can render nested slots.

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

Attaches a SlotStack to the request so downstream code can render nested slots.

Does nothing if the request already carries one, which is what keeps a slot rendered through a nested pipeline from starting a fresh stack.

When a context was injected, the rewritten request is republished through RequestState so anything reading Context::getRequest() sees the instance carrying the stack. A failure to publish is logged as a warning and not rethrown; the consequence is that a slot rendered from context-read code will not find a stack.

ParameterTypeDescription
$requestServerRequestInterface
$handlerRequestHandlerInterface

Returns ResponseInterface