class ThumbnailDownloader in Drupal 9
Same name and namespace in other branches
- 8 core/modules/media/src/Plugin/QueueWorker/ThumbnailDownloader.php \Drupal\media\Plugin\QueueWorker\ThumbnailDownloader
Process a queue of media items to fetch their thumbnails.
Plugin annotation
@QueueWorker(
id = "media_entity_thumbnail",
title = @Translation("Thumbnail downloader"),
cron = {"time" = 60}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\media\Plugin\QueueWorker\ThumbnailDownloader implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of ThumbnailDownloader
File
- core/
modules/ media/ src/ Plugin/ QueueWorker/ ThumbnailDownloader.php, line 19
Namespace
Drupal\media\Plugin\QueueWorkerView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
ThumbnailDownloader:: |
protected | property | The entity type manager service. | |
ThumbnailDownloader:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
ThumbnailDownloader:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
ThumbnailDownloader:: |
public | function |
Constructs a new class instance. Overrides PluginBase:: |