0 follower

Final Class Yiisoft\Queue\Provider\PredefinedQueueProvider

InheritanceYiisoft\Queue\Provider\PredefinedQueueProvider
ImplementsYiisoft\Queue\Provider\QueueProviderInterface

Queue provider that uses a pre-defined map of queue name to queue instance.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( array $queues )
$queues array

Map of queue name to queue instance.

throws Yiisoft\Queue\Provider\InvalidQueueConfigException

If a value in the array is not a {@see \Yiisoft\Queue\QueueInterface} instance.

                public function __construct(array $queues)
{
    foreach ($queues as $name => $queue) {
        if (!$queue instanceof QueueInterface) {
            throw new InvalidQueueConfigException(
                sprintf(
                    'Queue must implement "%s". For queue "%s" got "%s" instead.',
                    QueueInterface::class,
                    $name,
                    get_debug_type($queue),
                ),
            );
        }
    }
    $this->queues = $queues;
}

            
get() public method

public Yiisoft\Queue\QueueInterface get ( string|\BackedEnum $name )
$name string|\BackedEnum

                public function get(string|BackedEnum $name): QueueInterface
{
    $name = StringNormalizer::normalize($name);
    if (!array_key_exists($name, $this->queues)) {
        throw new QueueNotFoundException($name);
    }
    return $this->queues[$name];
}

            
getNames() public method

public array getNames ( )

                public function getNames(): array
{
    return array_keys($this->queues);
}

            
has() public method

public boolean has ( string|\BackedEnum $name )
$name string|\BackedEnum

                public function has(string|BackedEnum $name): bool
{
    $name = StringNormalizer::normalize($name);
    return array_key_exists($name, $this->queues);
}