View source
<?php
namespace Drupal\tamper;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
abstract class TamperBase extends PluginBase implements TamperInterface {
protected $sourceDefinition;
public function __construct(array $configuration, $plugin_id, $plugin_definition, SourceDefinitionInterface $source_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->sourceDefinition = $source_definition;
$this
->setConfiguration($configuration);
}
public function multiple() {
return FALSE;
}
public function getConfiguration() {
return $this->configuration;
}
public function getSetting($key) {
return isset($this->configuration[$key]) ? $this->configuration[$key] : NULL;
}
public function setConfiguration(array $configuration) {
unset($configuration['source_definition']);
$this->configuration = NestedArray::mergeDeep($this
->defaultConfiguration(), $configuration);
}
public function defaultConfiguration() {
return [];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return $form;
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}
}