Final Class Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher
| Inheritance | Yiisoft\ |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| dispatch() | Dispatch message through middleware to get response. | Yiisoft\ |
| hasMiddlewares() | Yiisoft\ |
|
| withFinishHandler() | Yiisoft\ |
|
| withMiddlewares() | Returns new instance with middleware handlers replaced with the ones provided. | Yiisoft\ |
| withMiddlewaresAdded() | Returns a new instance with additional middleware handlers added to the existing ones. | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $middlewareFactory | Yiisoft\ |
Factory used to instantiate middleware. |
| $middlewareDefinitions | array |
Middleware definitions. |
| $finishHandler | Yiisoft\ |
Finish message handler. |
public function __construct(
private readonly PushMiddlewareFactoryInterface $middlewareFactory,
private array $middlewareDefinitions,
private PushHandlerInterface $finishHandler,
) {}
Dispatch message through middleware to get response.
| public Yiisoft\ | ||
| $message | Yiisoft\ |
Message to pass to middleware. |
public function dispatch(MessageInterface $message): MessageInterface
{
if ($this->stack === null) {
$this->stack = new PushMiddlewareStack($this->buildMiddlewares(), $this->finishHandler);
}
return $this->stack->handlePush($message);
}
| public boolean hasMiddlewares ( ) | ||
| return | boolean |
Whether there are middleware defined in the dispatcher. |
|---|---|---|
public function hasMiddlewares(): bool
{
return $this->middlewareDefinitions !== [];
}
| public self withFinishHandler ( Yiisoft\ | ||
| $finishHandler | Yiisoft\ |
|
public function withFinishHandler(PushHandlerInterface $finishHandler): self
{
$instance = clone $this;
$instance->finishHandler = $finishHandler;
// Fixes a memory leak.
unset($instance->stack);
$instance->stack = null;
return $instance;
}
Returns new instance with middleware handlers replaced with the ones provided.
| public self withMiddlewares ( array $middlewareDefinitions ) | ||
| $middlewareDefinitions | array |
Middleware definitions. |
| return | self |
New instance of the {@see \ |
|---|---|---|
public function withMiddlewares(array $middlewareDefinitions): self
{
$instance = clone $this;
$instance->middlewareDefinitions = $middlewareDefinitions;
// Fixes a memory leak.
unset($instance->stack);
$instance->stack = null;
return $instance;
}
Returns a new instance with additional middleware handlers added to the existing ones.
| public self withMiddlewaresAdded ( array $middlewareDefinitions ) | ||
| $middlewareDefinitions | array |
Middleware definitions. |
| return | self |
New instance of the {@see \ |
|---|---|---|
public function withMiddlewaresAdded(array $middlewareDefinitions): self
{
return $this->withMiddlewares([...$this->middlewareDefinitions, ...$middlewareDefinitions]);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.