ContextReactionPluginBase.php in Context 8.0
File
src/ContextReactionPluginBase.php
View source
<?php
namespace Drupal\context;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
abstract class ContextReactionPluginBase extends PluginBase implements ContextReactionInterface {
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this
->setConfiguration($configuration);
}
public function getId() {
if (isset($this
->getConfiguration()['id'])) {
return $this
->getConfiguration()['id'];
}
return NULL;
}
public function getConfiguration() {
return [
'id' => $this
->getPluginId(),
] + $this->configuration;
}
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
return $this;
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
public function defaultConfiguration() {
return [
'saved' => FALSE,
];
}
public function calculateDependencies() {
return [];
}
}