Version 1
[yaffs-website] / vendor / drush / drush / tests / resources / modules / d8 / woot / src / Plugin / QueueWorker / WootRequeueException.php
diff --git a/vendor/drush/drush/tests/resources/modules/d8/woot/src/Plugin/QueueWorker/WootRequeueException.php b/vendor/drush/drush/tests/resources/modules/d8/woot/src/Plugin/QueueWorker/WootRequeueException.php
new file mode 100644 (file)
index 0000000..6830e56
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\woot\Plugin\QueueWorker;
+
+use Drupal\Core\Queue\QueueWorkerBase;
+use Drupal\Core\Queue\RequeueException;
+
+/**
+ * Queue worker used to test RequeueException.
+ *
+ * @QueueWorker(
+ *   id = "woot_requeue_exception",
+ *   title = @Translation("RequeueException test"),
+ *   cron = {"time" = 60}
+ * )
+ */
+class WootRequeueException extends QueueWorkerBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function processItem($data) {
+    $state = \Drupal::state();
+    if (!$state->get('woot_requeue_exception')) {
+      $state->set('woot_requeue_exception', 1);
+      throw new RequeueException('I am not done yet!');
+    }
+    else {
+      $state->set('woot_requeue_exception', 2);
+    }
+  }
+
+}