6830e56d02f53963570f1de65611d1965bba68fc
[yaffs-website] / vendor / drush / drush / tests / resources / modules / d8 / woot / src / Plugin / QueueWorker / WootRequeueException.php
1 <?php
2
3 namespace Drupal\woot\Plugin\QueueWorker;
4
5 use Drupal\Core\Queue\QueueWorkerBase;
6 use Drupal\Core\Queue\RequeueException;
7
8 /**
9  * Queue worker used to test RequeueException.
10  *
11  * @QueueWorker(
12  *   id = "woot_requeue_exception",
13  *   title = @Translation("RequeueException test"),
14  *   cron = {"time" = 60}
15  * )
16  */
17 class WootRequeueException extends QueueWorkerBase {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function processItem($data) {
23     $state = \Drupal::state();
24     if (!$state->get('woot_requeue_exception')) {
25       $state->set('woot_requeue_exception', 1);
26       throw new RequeueException('I am not done yet!');
27     }
28     else {
29       $state->set('woot_requeue_exception', 2);
30     }
31   }
32
33 }