Provides methods for creating and manipulating a "queue" of middlewares. This queue is used to process a request and generate response via \Cake\Http\Runner.
Constructor
Append a middleware to the end of the queue.
Get the number of connected middleware layers.
Returns the current middleware.
Insert a middleware object after the first matching class.
Insert a middleware at a specific index.
Insert a middleware before the first matching class.
Return the key of the middleware.
Moves the current position to the next middleware.
Prepend a middleware to the start of the queue.
Alias for MiddlewareQueue::add().
Resolve middleware name to a PSR 15 compliant middleware instance.
Rewinds back to the first element of the queue.
Seeks to a given position in the queue.
Checks if current position is valid.
__construct(array $middleware = [])
Constructor
array
$middleware optional The list of middleware to append.
add(Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware): $this
Append a middleware to the end of the queue.
Psr\Http\Server\MiddlewareInterfaceClosure|array|string
$middleware The middleware(s) to append.
$this
count(): int
Get the number of connected middleware layers.
Implement the Countable interface.
int
current(): Psr\Http\Server\MiddlewareInterface
Returns the current middleware.
Psr\Http\Server\MiddlewareInterface
insertAfter(string $class, Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware): $this
Insert a middleware object after the first matching class.
Finds the index of the first middleware that matches the provided class, and inserts the supplied middleware after it. If the class is not found, this method will behave like add().
string
$class The classname to insert the middleware before.
Psr\Http\Server\MiddlewareInterfaceClosure|string
$middleware The middleware to insert.
$this
insertAt(int $index, Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware): $this
Insert a middleware at a specific index.
If the index already exists, the new middleware will be inserted, and the existing element will be shifted one index greater.
int
$index The index to insert at.
Psr\Http\Server\MiddlewareInterfaceClosure|string
$middleware The middleware to insert.
$this
insertBefore(string $class, Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware): $this
Insert a middleware before the first matching class.
Finds the index of the first middleware that matches the provided class, and inserts the supplied middleware before it.
string
$class The classname to insert the middleware before.
Psr\Http\Server\MiddlewareInterfaceClosure|string
$middleware The middleware to insert.
$this
LogicException
key(): int
Return the key of the middleware.
int
next(): void
Moves the current position to the next middleware.
void
prepend(Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware): $this
Prepend a middleware to the start of the queue.
Psr\Http\Server\MiddlewareInterfaceClosure|array|string
$middleware The middleware(s) to prepend.
$this
push(Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware): $this
Alias for MiddlewareQueue::add().
Psr\Http\Server\MiddlewareInterfaceClosure|array|string
$middleware The middleware(s) to append.
$this
resolve(Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware): Psr\Http\Server\MiddlewareInterface
Resolve middleware name to a PSR 15 compliant middleware instance.
Psr\Http\Server\MiddlewareInterfaceClosure|string
$middleware The middleware to resolve.
Psr\Http\Server\MiddlewareInterface
RuntimeException
rewind(): void
Rewinds back to the first element of the queue.
void
seek(int $position): void
Seeks to a given position in the queue.
int
$position The position to seek to.
void
valid(): bool
Checks if current position is valid.
bool
Internal position for iterator.
int
The queue of middlewares.
array<int, mixed>
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Http.MiddlewareQueue.html