8dc5538cef9ca21ed5c0555013588c4871a81913
[yaffs-website] / web / modules / contrib / media_entity / src / Plugin / QueueWorker / thumbnailDownloader.php
1 <?php
2
3 namespace Drupal\media_entity\Plugin\QueueWorker;
4
5 use Drupal\media_entity\Entity\Media;
6 use Drupal\Core\Queue\QueueWorkerBase;
7
8 /**
9  * Download images.
10  *
11  * @QueueWorker(
12  *   id = "media_entity_thumbnail",
13  *   title = @Translation("Thumbnail downloader"),
14  *   cron = {"time" = 60}
15  * )
16  */
17 class ThumbnailDownloader extends QueueWorkerBase {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function processItem($data) {
23     if ($entity = Media::load($data['id'])) {
24       // Indicate that the entity is being processed from a queue and that
25       // thumbnail images should be downloaded.
26       $entity->setQueuedThumbnailDownload();
27       $entity->save();
28     }
29   }
30
31 }