1. 8.2.x core/lib/Drupal/Core/Annotation/QueueWorker.php
  2. 8.0.x core/lib/Drupal/Core/Annotation/QueueWorker.php
  3. 8.1.x core/lib/Drupal/Core/Annotation/QueueWorker.php
  4. 8.3.x core/lib/Drupal/Core/Annotation/QueueWorker.php

Namespace

Drupal\Core\Annotation

File

core/lib/Drupal/Core/Annotation/QueueWorker.php
View source
  1. <?php
  2. namespace Drupal\Core\Annotation;
  3. use Drupal\Component\Annotation\Plugin;
  4. /**
  5. * Declare a worker class for processing a queue item.
  6. *
  7. * Worker plugins are used by some queues for processing the individual items
  8. * in the queue. In that case, the ID of the worker plugin needs to match the
  9. * machine name of a queue, so that you can retrieve the queue back end by
  10. * calling \Drupal\Core\Queue\QueueFactory::get($plugin_id).
  11. *
  12. * \Drupal\Core\Cron::processQueues() processes queues that use workers; they
  13. * can also be processed outside of the cron process.
  14. *
  15. * Some queues do not use worker plugins: you can create queues, add items to
  16. * them, claim them, etc. without using a QueueWorker plugin. However, you will
  17. * need to take care of processing the items in the queue in that case. You can
  18. * look at \Drupal\Core\Cron::processQueues() for an example of how to process
  19. * a queue that uses workers, and adapt it to your queue.
  20. *
  21. * Plugin Namespace: Plugin\QueueWorker
  22. *
  23. * For a working example, see
  24. * \Drupal\aggregator\Plugin\QueueWorker\AggregatorRefresh.
  25. *
  26. * @see \Drupal\Core\Queue\QueueWorkerInterface
  27. * @see \Drupal\Core\Queue\QueueWorkerBase
  28. * @see \Drupal\Core\Queue\QueueWorkerManager
  29. * @see plugin_api
  30. *
  31. * @Annotation
  32. */
  33. class QueueWorker extends Plugin {
  34. /**
  35. * The plugin ID.
  36. *
  37. * @var string
  38. */
  39. public $id;
  40. /**
  41. * The human-readable title of the plugin.
  42. *
  43. * @ingroup plugin_translatable
  44. *
  45. * @var \Drupal\Core\Annotation\Translation
  46. */
  47. public $title;
  48. /**
  49. * An associative array containing the optional key:
  50. * - time: (optional) How much time Drupal cron should spend on calling
  51. * this worker in seconds. Defaults to 15.
  52. *
  53. * @var array (optional)
  54. */
  55. public $cron;
  56. }

Classes

Namesort descending Description
QueueWorker Declare a worker class for processing a queue item.