Final Class Yiisoft\Queue\Message\Handler\HandlerResolver
| Inheritance | Yiisoft\ |
|---|
Resolves message handlers from configuration, a DI container, or a callable factory.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| resolve() | Get a handler for the given message type. | Yiisoft\ |
Method Details
| public mixed __construct ( (array|callable|\ | ||
| $handlers | (array|callable|\ |
Handler definitions indexed by message type. |
| $container | \ |
Container used to resolve handlers. |
| $callableDependencyContainer | \ |
Container used to resolve callable handler dependencies. If not set, the main container is used. |
public function __construct(
private readonly array $handlers,
private readonly ContainerInterface $container,
?ContainerInterface $callableDependencyContainer = null,
) {
$this->callableFactory = new CallableFactory($this->container, $callableDependencyContainer);
}
Get a handler for the given message type.
| public Yiisoft\ | ||
| $messageType | string |
Message type. Must be a non-empty string. |
| throws | Yiisoft\ |
If no handler exists for the message type. |
|---|---|---|
| throws | Yiisoft\ |
If the handler definition is configured incorrectly. |
public function resolve(string $messageType): HandlerInterface
{
if (array_key_exists($messageType, $this->cache)) {
return $this->cache[$messageType];
}
$this->cache[$messageType] = $this->internalResolve($messageType);
return $this->cache[$messageType];
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.