5ee43fe9106bf605507d0bbcd50c9d1f07ac4a18
[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   /**
21    * {@inheritdoc}
22    */
23     public function processItem($data)
24     {
25         $state = \Drupal::state();
26         if (!$state->get('woot_requeue_exception')) {
27             $state->set('woot_requeue_exception', 1);
28             throw new RequeueException('I am not done yet!');
29         } else {
30             $state->set('woot_requeue_exception', 2);
31         }
32     }
33 }