Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Queue/QueueFactory.php \Drupal\Core\Queue\QueueFactory::get()
  2. 9 core/lib/Drupal/Core/Queue/QueueFactory.php \Drupal\Core\Queue\QueueFactory::get()

Constructs a new queue.

Parameters

string $name: The name of the queue to work with.

bool $reliable: (optional) TRUE if the ordering of items and guaranteeing every item executes at least once is important, FALSE if scalability is the main concern. Defaults to FALSE.

Return value

\Drupal\Core\Queue\QueueInterface A queue implementation for the given name.

File

core/lib/Drupal/Core/Queue/QueueFactory.php, line 50

Class

QueueFactory
Defines the queue factory.

Namespace

Drupal\Core\Queue

Code

public function get($name, $reliable = FALSE) {
  if (!isset($this->queues[$name])) {

    // If it is a reliable queue, check the specific settings first.
    if ($reliable) {
      $service_name = $this->settings
        ->get('queue_reliable_service_' . $name);
    }

    // If no reliable queue was defined, check the service and global
    // settings, fall back to queue.database.
    if (empty($service_name)) {
      $service_name = $this->settings
        ->get('queue_service_' . $name, $this->settings
        ->get('queue_default', 'queue.database'));
    }
    $factory = $this->container
      ->get($service_name);
    if (!$factory instanceof QueueFactoryInterface) {
      @trigger_error(sprintf('Not implementing %s in %s is deprecated in drupal:10.3.0 and the factory will not be discovered in drupal:11.0.0. Implement the interface in your factory class. See https://www.drupal.org/node/3417034', QueueFactoryInterface::class, $factory::class), E_USER_DEPRECATED);
    }
    $this->queues[$name] = $factory
      ->get($name);
  }
  return $this->queues[$name];
}