function Drupal::queue

Same name in other branches
  1. 9 core/lib/Drupal.php \Drupal::queue()
  2. 8.9.x core/lib/Drupal.php \Drupal::queue()
  3. 11.x core/lib/Drupal.php \Drupal::queue()

Returns a queue for the given queue name.

The following values can be set in your settings.php file's $settings array to define which services are used for queues:

  • queue_reliable_service_$name: The container service to use for the reliable queue $name.
  • queue_service_$name: The container service to use for the queue $name.
  • queue_default: The container service to use by default for queues without overrides. This defaults to 'queue.database'.

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 The queue object for a given name.

11 calls to Drupal::queue()
CronQueueTest::testQueueWorkerDeriver in core/modules/system/tests/src/Kernel/System/CronQueueTest.php
Tests that cron queues from derivers work.
CronQueueTest::testSuspendQueueException in core/modules/system/tests/src/Kernel/System/CronQueueTest.php
Tests suspend queue exception is handled properly.
DrupalTest::testQueue in core/tests/Drupal/Tests/Core/DrupalTest.php
Tests the queue() method.
hook_cron in core/core.api.php
Perform periodic actions.
LocaleUpdateCronTest::testUpdateCron in core/modules/locale/tests/src/Functional/LocaleUpdateCronTest.php
Tests interface translation update using cron.

... See full list

File

core/lib/Drupal.php, line 453

Class

Drupal
Static Service Container wrapper.

Code

public static function queue($name, $reliable = FALSE) {
    return static::getContainer()->get('queue')
        ->get($name, $reliable);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.