Class MiddlewareQueue
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.
Properties summary
Method Summary
Method Detail
__construct() public
__construct(array $middleware)
Constructor
Parameters
-
array$middleware optional The list of middleware to append.
add() public
add(mixed $middleware)
Append a middleware to the end of the queue.
Parameters
-
string|array|\Closure|\Psr\Http\Server\MiddlewareInterface$middleware The middleware(s) to append.
Returns
$thiscount() public
count()
Get the number of connected middleware layers.
Implement the Countable interface.
Returns
intcurrent() public
current()
Returns the current middleware.
Returns
\Psr\Http\Server\MiddlewareInterfaceSee Also
insertAfter() public
insertAfter(string $class, mixed $middleware)
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().
Parameters
-
string$class The classname to insert the middleware before.
-
string|\Closure|\Psr\Http\Server\MiddlewareInterface$middleware The middleware to insert.
Returns
$thisinsertAt() public
insertAt(int $index, mixed $middleware)
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.
Parameters
-
int$index The index to insert at.
-
string|\Closure|\Psr\Http\Server\MiddlewareInterface$middleware The middleware to insert.
Returns
$thisinsertBefore() public
insertBefore(string $class, mixed $middleware)
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.
Parameters
-
string$class The classname to insert the middleware before.
-
string|\Closure|\Psr\Http\Server\MiddlewareInterface$middleware The middleware to insert.
Returns
$thisThrows
LogicExceptionIf middleware to insert before is not found.
key() public
key()
Return the key of the middleware.
Returns
intSee Also
next() public
next()
Moves the current position to the next middleware.
See Also
prepend() public
prepend(mixed $middleware)
Prepend a middleware to the start of the queue.
Parameters
-
string|array|\Closure|\Psr\Http\Server\MiddlewareInterface$middleware The middleware(s) to prepend.
Returns
$thispush() public
push(mixed $middleware)
Alias for MiddlewareQueue::add().
Parameters
-
string|array|\Closure|\Psr\Http\Server\MiddlewareInterface$middleware The middleware(s) to append.
Returns
$thisSee Also
resolve() protected
resolve(mixed $middleware)
Resolve middleware name to a PSR 15 compliant middleware instance.
Parameters
-
string|\Closure|\Psr\Http\Server\MiddlewareInterface$middleware The middleware to resolve.
Returns
\Psr\Http\Server\MiddlewareInterfaceThrows
RuntimeExceptionIf Middleware not found.
rewind() public
rewind()
Rewinds back to the first element of the queue.
See Also
seek() public
seek(mixed $position)
Seeks to a given position in the queue.
Parameters
-
int$position The position to seek to.
See Also
valid() public
valid()
Checks if current position is valid.
Returns
boolSee Also
Property Detail
$position protected
Internal position for iterator.
Type
int$queue protected
The queue of middlewares.
Type
array
© 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.0/class-Cake.Http.MiddlewareQueue.html