MediaThumbnailBase.php in Media Thumbnails 8
Namespace
Drupal\media_thumbnails\PluginFile
src/Plugin/MediaThumbnailBase.phpView source
<?php
namespace Drupal\media_thumbnails\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Base class for Media thumbnail plugins.
*/
abstract class MediaThumbnailBase extends PluginBase implements MediaThumbnailInterface, ContainerFactoryPluginInterface {
use StringTranslationTrait;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactory
*/
protected $config;
/**
* The file system interface.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* The logger interface.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Constructs a new Media Thumbnail class.
*
* @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\Config\ConfigFactory $config
* The config factory.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* The file system.
* @param \Psr\Log\LoggerInterface $logger
* The logger.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactory $config, FileSystemInterface $file_system, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->config = $config;
$this->fileSystem = $file_system;
$this->logger = $logger;
}
/**
* Injects some default services.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The service container.
* @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.
*
* @return \Drupal\media_thumbnails\Plugin\MediaThumbnailBase
* The instance.
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) : MediaThumbnailBase {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'), $container
->get('file_system'), $container
->get('logger.media_thumbnails'));
}
}
Classes
Name | Description |
---|---|
MediaThumbnailBase | Base class for Media thumbnail plugins. |