ImageEffectsPluginBase.php in Image Effects 8.2
File
src/Plugin/ImageEffectsPluginBase.php
View source
<?php
namespace Drupal\image_effects\Plugin;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class ImageEffectsPluginBase extends PluginBase implements ImageEffectsPluginBaseInterface {
protected $pluginType;
protected $config;
protected $logger;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, LoggerInterface $logger) {
$this->config = $config_factory
->getEditable('image_effects.settings');
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->pluginType = $configuration['plugin_type'];
$config = $this->config
->get($this->pluginType . '.plugin_settings.' . $plugin_id);
$this
->setConfiguration(array_merge($this
->defaultConfiguration(), is_array($config) ? $config : []));
$this->logger = $logger;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'), $container
->get('logger.channel.image_effects'));
}
public function defaultConfiguration() {
return [];
}
public function getConfiguration() {
return $this->configuration;
}
public function setConfiguration(array $configuration) {
$this->configuration = $configuration;
}
public function calculateDependencies() {
return [];
}
public static function isAvailable() {
return TRUE;
}
public function getType() {
return $this->pluginType;
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state, array $ajax_settings = []) {
return [];
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}
public function selectionElement(array $options = []) {
return [];
}
}