class ImageStylesPregenerator in Image Style Warmer 8
Executes interface image styles pregeneration queue tasks.
Plugin annotation
@QueueWorker(
id = "image_style_warmer_pregenerator",
title = @Translation("Pregenerate image styles"),
cron = {"time" = 60}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\image_style_warmer\Plugin\QueueWorker\ImageStylesPregenerator implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of ImageStylesPregenerator
File
- src/
Plugin/ QueueWorker/ ImageStylesPregenerator.php, line 22
Namespace
Drupal\image_style_warmer\Plugin\QueueWorkerView source
class ImageStylesPregenerator extends QueueWorkerBase implements ContainerFactoryPluginInterface {
/**
* The image style warmer settings.
*
* @var \Drupal\Core\Config\Config
*/
protected $config;
/**
* The file entity storage.
*
* @var \Drupal\file\FileStorageInterface
*/
protected $fileStorage;
/**
* The image style warmer service.
*
* @var \Drupal\image_style_warmer\ImageStylesWarmerInterface
*/
protected $imageStylesWarmer;
/**
* Constructs a new ImageStylePregenerator object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param array $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Config\Config $image_style_warmer_settings
* The image style warmer settings.
* @param \Drupal\Core\Entity\EntityStorageInterface $file_storage
* The file storage.
* @param \Drupal\image_style_warmer\ImageStylesWarmerInterface $image_styles_warmer
* The image style warmer service.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, Config $image_style_warmer_settings, EntityStorageInterface $file_storage, ImageStylesWarmerInterface $image_styles_warmer) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->config = $image_style_warmer_settings;
$this->fileStorage = $file_storage;
$this->imageStylesWarmer = $image_styles_warmer;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory')
->get('image_style_warmer.settings'), $container
->get('entity_type.manager')
->getStorage('file'), $container
->get('image_style_warmer.warmer'));
}
/**
* {@inheritdoc}
*/
public function processItem($data) {
$file_id = $data['file_id'];
$queueImageStyles = $data['image_styles'];
if (!empty($queueImageStyles) && ($file = $this->fileStorage
->load($file_id)) && $file instanceof FileInterface) {
$this->imageStylesWarmer
->doWarmUp($file, $queueImageStyles);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ImageStylesPregenerator:: |
protected | property | The image style warmer settings. | |
ImageStylesPregenerator:: |
protected | property | The file entity storage. | |
ImageStylesPregenerator:: |
protected | property | The image style warmer service. | |
ImageStylesPregenerator:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
ImageStylesPregenerator:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
ImageStylesPregenerator:: |
public | function |
Constructs a new ImageStylePregenerator object. Overrides PluginBase:: |
|
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:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. |