class QueueWorker
Same name in this branch
- 10 core/lib/Drupal/Core/Annotation/QueueWorker.php \Drupal\Core\Annotation\QueueWorker
Same name in other branches
- 9 core/lib/Drupal/Core/Annotation/QueueWorker.php \Drupal\Core\Annotation\QueueWorker
- 8.9.x core/lib/Drupal/Core/Annotation/QueueWorker.php \Drupal\Core\Annotation\QueueWorker
- 11.x core/lib/Drupal/Core/Queue/Attribute/QueueWorker.php \Drupal\Core\Queue\Attribute\QueueWorker
- 11.x core/lib/Drupal/Core/Annotation/QueueWorker.php \Drupal\Core\Annotation\QueueWorker
Declare a worker class for processing a queue item.
Worker plugins are used by some queues for processing the individual items in the queue. In that case, the ID of the worker plugin needs to match the machine name of a queue, so that you can retrieve the queue back end by calling \Drupal\Core\Queue\QueueFactory::get($plugin_id).
\Drupal\Core\Cron::processQueues() processes queues that use workers; they can also be processed outside of the cron process.
Some queues do not use worker plugins: you can create queues, add items to them, claim them, etc. without using a QueueWorker plugin. However, you will need to take care of processing the items in the queue in that case. You can look at \Drupal\Core\Cron::processQueues() for an example of how to process a queue that uses workers, and adapt it to your queue.
Plugin Namespace: Plugin\QueueWorker
For a working example, see \Drupal\locale\Plugin\QueueWorker\LocaleTranslation.
Hierarchy
- class \Drupal\Component\Plugin\Attribute\AttributeBase implements \Drupal\Component\Plugin\Attribute\AttributeInterface
- class \Drupal\Component\Plugin\Attribute\Plugin extends \Drupal\Component\Plugin\Attribute\AttributeBase
- class \Drupal\Core\Queue\Attribute\QueueWorker extends \Drupal\Component\Plugin\Attribute\Plugin
- class \Drupal\Component\Plugin\Attribute\Plugin extends \Drupal\Component\Plugin\Attribute\AttributeBase
Expanded class hierarchy of QueueWorker
See also
\Drupal\Core\Queue\QueueWorkerInterface
\Drupal\Core\Queue\QueueWorkerBase
\Drupal\Core\Queue\QueueWorkerManager
Related topics
10 files declare their use of QueueWorker
- CronQueueTestDatabaseDelayException.php in core/
modules/ system/ tests/ modules/ cron_queue_test/ src/ Plugin/ QueueWorker/ CronQueueTestDatabaseDelayException.php - CronQueueTestDeriverQueue.php in core/
modules/ system/ tests/ modules/ cron_queue_test/ src/ Plugin/ QueueWorker/ CronQueueTestDeriverQueue.php - CronQueueTestException.php in core/
modules/ system/ tests/ modules/ cron_queue_test/ src/ Plugin/ QueueWorker/ CronQueueTestException.php - CronQueueTestLeaseTime.php in core/
modules/ system/ tests/ modules/ cron_queue_test/ src/ Plugin/ QueueWorker/ CronQueueTestLeaseTime.php - CronQueueTestMemoryDelayException.php in core/
modules/ system/ tests/ modules/ cron_queue_test/ src/ Plugin/ QueueWorker/ CronQueueTestMemoryDelayException.php
File
-
core/
lib/ Drupal/ Core/ Queue/ Attribute/ QueueWorker.php, line 37
Namespace
Drupal\Core\Queue\AttributeView source
class QueueWorker extends Plugin {
/**
* @param string $id
* The plugin ID.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $title
* The human-readable title of the plugin.
* @param array|null $cron
* (optional) An associative array of settings for cron. The array has one
* key, time, which is set to the time Drupal cron should spend on calling
* this worker in seconds. The default is set in
* \Drupal\Core\Queue\QueueWorkerManager::processDefinition().
* @param class-string|null $deriver
* (optional) The deriver class.
*/
public function __construct(string $id, ?TranslatableMarkup $title = NULL, ?array $cron = NULL, ?string $deriver = NULL) {
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
AttributeBase::$class | protected | property | The class used for this attribute class. | ||
AttributeBase::$provider | protected | property | The provider of the attribute class. | ||
AttributeBase::get | public | function | Overrides AttributeInterface::get | 6 | |
AttributeBase::getClass | public | function | Overrides AttributeInterface::getClass | 1 | |
AttributeBase::getId | public | function | Overrides AttributeInterface::getId | ||
AttributeBase::getProvider | public | function | Overrides AttributeInterface::getProvider | ||
AttributeBase::setClass | public | function | Overrides AttributeInterface::setClass | 1 | |
AttributeBase::setProvider | public | function | Overrides AttributeInterface::setProvider | ||
QueueWorker::__construct | public | function | Overrides Plugin::__construct |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.