You are here

class QueueFactory in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Queue/QueueFactory.php \Drupal\Core\Queue\QueueFactory

Defines the queue factory.

Hierarchy

Expanded class hierarchy of QueueFactory

2 files declare their use of QueueFactory
Cron.php in core/lib/Drupal/Core/Cron.php
Contains \Drupal\Core\Cron.
UpdateProcessor.php in core/modules/update/src/UpdateProcessor.php
Contains \Drupal\update\UpdateProcessor.
1 string reference to 'QueueFactory'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses QueueFactory
queue in core/core.services.yml
Drupal\Core\Queue\QueueFactory

File

core/lib/Drupal/Core/Queue/QueueFactory.php, line 17
Contains \Drupal\Core\Queue\QueueFactory.

Namespace

Drupal\Core\Queue
View source
class QueueFactory implements ContainerAwareInterface {
  use ContainerAwareTrait;

  /**
   * Instantiated queues, keyed by name.
   *
   * @var array
   */
  protected $queues = array();

  /**
   * The settings object.
   *
   * @var \Drupal\Core\Site\Settings
   */
  protected $settings;

  /**
   * Constructs a queue factory.
   */
  function __construct(Settings $settings) {
    $this->settings = $settings;
  }

  /**
   * Constructs a new queue.
   *
   * @param string $name
   *   The name of the queue to work with.
   * @param 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 \Drupal\Core\Queue\QueueInterface
   *   A queue implementation for the given name.
   */
  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'));
      }
      $this->queues[$name] = $this->container
        ->get($service_name)
        ->get($name);
    }
    return $this->queues[$name];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContainerAwareTrait::$container protected property
ContainerAwareTrait::setContainer public function Sets the Container associated with this Controller.
QueueFactory::$queues protected property Instantiated queues, keyed by name.
QueueFactory::$settings protected property The settings object.
QueueFactory::get public function Constructs a new queue.
QueueFactory::__construct function Constructs a queue factory.