class QueueWorkerManager

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Queue/QueueWorkerManager.php \Drupal\Core\Queue\QueueWorkerManager
  2. 10 core/lib/Drupal/Core/Queue/QueueWorkerManager.php \Drupal\Core\Queue\QueueWorkerManager
  3. 8.9.x core/lib/Drupal/Core/Queue/QueueWorkerManager.php \Drupal\Core\Queue\QueueWorkerManager

Defines the queue worker manager.

Hierarchy

Expanded class hierarchy of QueueWorkerManager

See also

\Drupal\Core\Queue\QueueWorkerInterface

\Drupal\Core\Queue\QueueWorkerBase

\Drupal\Core\Annotation\QueueWorker

Plugin API

1 string reference to 'QueueWorkerManager'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses QueueWorkerManager
plugin.manager.queue_worker in core/core.services.yml
Drupal\Core\Queue\QueueWorkerManager

File

core/lib/Drupal/Core/Queue/QueueWorkerManager.php, line 17

Namespace

Drupal\Core\Queue
View source
class QueueWorkerManager extends DefaultPluginManager implements QueueWorkerManagerInterface {
  
  /**
   * Constructs a QueueWorkerManager object.
   *
   * @param \Traversable $namespaces
   *   An object that implements \Traversable which contains the root paths
   *   keyed by the corresponding namespace to look for plugin implementations.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
   *   Cache backend instance to use.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   */
  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
    parent::__construct('Plugin/QueueWorker', $namespaces, $module_handler, 'Drupal\\Core\\Queue\\QueueWorkerInterface', 'Drupal\\Core\\Annotation\\QueueWorker');
    $this->setCacheBackend($cache_backend, 'queue_plugins');
    $this->alterInfo('queue_info');
  }
  
  /**
   * {@inheritdoc}
   */
  public function processDefinition(&$definition, $plugin_id) {
    parent::processDefinition($definition, $plugin_id);
    // Safeguard to ensure the default lease time is used in the case of a
    // malformed queue worker annotation where cron is specified without a time,
    // or an invalid time is provided.
    //
    // @see \Drupal\Core\Cron::processQueues()
    if (isset($definition['cron'])) {
      $time = $definition['cron']['time'] ?? 0;
      if ($time <= 0) {
        $definition['cron']['time'] = self::DEFAULT_QUEUE_CRON_TIME;
      }
    }
  }
  
  /**
   * {@inheritdoc}
   *
   * @return \Drupal\Core\Queue\QueueWorkerInterface
   */
  public function createInstance($plugin_id, array $configuration = []) {
    return parent::createInstance($plugin_id, $configuration);
  }

}

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