View source
<?php
namespace Drupal\openlayers;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\openlayers\OpenlayersPluginInterface;
abstract class OpenlayersPluginBase extends PluginBase implements OpenlayersPluginInterface, ContainerFactoryPluginInterface {
protected $uuid;
protected $weight = '';
protected $logger;
public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this
->setConfiguration($configuration);
$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('logger.factory')
->get('image'));
}
public function transformDimensions(array &$dimensions, $uri) {
}
public function getDerivativeExtension($extension) {
return $extension;
}
public function getSummary() {
return [
'#markup' => '',
'#effect' => [
'id' => $this->pluginDefinition['id'],
'label' => $this
->label(),
'description' => $this->pluginDefinition['description'],
],
];
}
public function label() {
return $this->pluginDefinition['label'];
}
public function getUuid() {
return $this->uuid;
}
public function setWeight($weight) {
$this->weight = $weight;
return $this;
}
public function getWeight() {
return $this->weight;
}
public function getConfiguration() {
$definition = $this
->getPluginDefinition();
return [
'uuid' => $this
->getUuid(),
'id' => $this
->getPluginId(),
'weight' => $this
->getWeight(),
'data' => $this->configuration,
'ol_id' => isset($definition['ol_id']) ? $definition['ol_id'] : '???',
];
}
public function setConfiguration(array $configuration) {
$configuration += [
'data' => [],
'uuid' => '',
'weight' => '',
];
$this->configuration = $configuration['data'] + $this
->defaultConfiguration();
$this->uuid = $configuration['uuid'];
$this->weight = $configuration['weight'];
return $this;
}
public function defaultConfiguration() {
return [];
}
public function calculateDependencies() {
return [];
}
}