Final Class Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher
| Inheritance | Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher | |
| dispatch() | Dispatch message through middleware to get response. | Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher |
| hasMiddlewares() | Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher | |
| withFinishHandler() | Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher | |
| withMiddlewares() | Returns new instance with middleware handlers replaced with the ones provided. | Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher |
| withMiddlewaresAdded() | Returns a new instance with additional middleware handlers added to the existing ones. | Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher |
Method Details
| public mixed __construct ( Yiisoft\Queue\Middleware\Push\PushMiddlewareFactoryInterface $middlewareFactory, array $middlewareDefinitions, Yiisoft\Queue\Middleware\Push\PushHandlerInterface $finishHandler ) | ||
| $middlewareFactory | Yiisoft\Queue\Middleware\Push\PushMiddlewareFactoryInterface |
Factory used to instantiate middleware. |
| $middlewareDefinitions | array |
Middleware definitions. |
| $finishHandler | Yiisoft\Queue\Middleware\Push\PushHandlerInterface |
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\Queue\Message\MessageInterface dispatch ( Yiisoft\Queue\Message\MessageInterface $message ) | ||
| $message | Yiisoft\Queue\Message\MessageInterface |
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\Queue\Middleware\Push\PushHandlerInterface $finishHandler ) | ||
| $finishHandler | Yiisoft\Queue\Middleware\Push\PushHandlerInterface | |
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 \Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher} |
|---|---|---|
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 \Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher} |
|---|---|---|
public function withMiddlewaresAdded(array $middlewareDefinitions): self
{
return $this->withMiddlewares([...$this->middlewareDefinitions, ...$middlewareDefinitions]);
}
Signup or Login in order to comment.