Version 1
[yaffs-website] / web / modules / contrib / media_entity / src / Plugin / QueueWorker / thumbnailDownloader.php
diff --git a/web/modules/contrib/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php b/web/modules/contrib/media_entity/src/Plugin/QueueWorker/thumbnailDownloader.php
new file mode 100644 (file)
index 0000000..8dc5538
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+namespace Drupal\media_entity\Plugin\QueueWorker;
+
+use Drupal\media_entity\Entity\Media;
+use Drupal\Core\Queue\QueueWorkerBase;
+
+/**
+ * Download images.
+ *
+ * @QueueWorker(
+ *   id = "media_entity_thumbnail",
+ *   title = @Translation("Thumbnail downloader"),
+ *   cron = {"time" = 60}
+ * )
+ */
+class ThumbnailDownloader extends QueueWorkerBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function processItem($data) {
+    if ($entity = Media::load($data['id'])) {
+      // Indicate that the entity is being processed from a queue and that
+      // thumbnail images should be downloaded.
+      $entity->setQueuedThumbnailDownload();
+      $entity->save();
+    }
+  }
+
+}