CronQueueTestSuspendQueue.php

Namespace

Drupal\cron_queue_test\Plugin\QueueWorker

File

core/modules/system/tests/modules/cron_queue_test/src/Plugin/QueueWorker/CronQueueTestSuspendQueue.php

View source
<?php

declare (strict_types=1);
namespace Drupal\cron_queue_test\Plugin\QueueWorker;

use Drupal\Core\Queue\Attribute\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\Core\Queue\SuspendQueueException;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * A queue worker for testing suspending queue run.
 */
class CronQueueTestSuspendQueue extends QueueWorkerBase {
  
  /**
   * The plugin ID.
   */
  public const PLUGIN_ID = 'cron_queue_test_suspend';
  
  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    if ($data === 'suspend') {
      throw new SuspendQueueException('The queue is broken.');
    }
    // Do nothing otherwise.
  }

}

Classes

Title Deprecated Summary
CronQueueTestSuspendQueue A queue worker for testing suspending queue run.

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