class ThumbnailDownloader

Same name in other branches
  1. 9 core/modules/media/src/Plugin/QueueWorker/ThumbnailDownloader.php \Drupal\media\Plugin\QueueWorker\ThumbnailDownloader
  2. 8.9.x core/modules/media/src/Plugin/QueueWorker/ThumbnailDownloader.php \Drupal\media\Plugin\QueueWorker\ThumbnailDownloader
  3. 10 core/modules/media/src/Plugin/QueueWorker/ThumbnailDownloader.php \Drupal\media\Plugin\QueueWorker\ThumbnailDownloader

Process a queue of media items to fetch their thumbnails.

Hierarchy

Expanded class hierarchy of ThumbnailDownloader

File

core/modules/media/src/Plugin/QueueWorker/ThumbnailDownloader.php, line 15

Namespace

Drupal\media\Plugin\QueueWorker
View source
class ThumbnailDownloader extends QueueWorkerBase implements ContainerFactoryPluginInterface {
    
    /**
     * The entity type manager service.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * Constructs a new class instance.
     *
     * @param array $configuration
     *   A configuration array containing information about the plugin instance.
     * @param string $plugin_id
     *   The plugin ID for the plugin instance.
     * @param mixed $plugin_definition
     *   The plugin implementation definition.
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   Entity type manager service.
     */
    public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->entityTypeManager = $entity_type_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
        return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity_type.manager'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function processItem($data) {
        
        /** @var \Drupal\media\Entity\Media $media */
        if ($media = $this->entityTypeManager
            ->getStorage('media')
            ->load($data['id'])) {
            $media->updateQueuedThumbnail();
            $media->save();
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ThumbnailDownloader::$entityTypeManager protected property The entity type manager service.
ThumbnailDownloader::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
ThumbnailDownloader::processItem public function
ThumbnailDownloader::__construct public function Constructs a new class instance.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.