abstract class TamperPluginBase in Tamper 7
Base class for Tamper plugins.
Hierarchy
- class \TamperPluginBase implements TamperPluginInterface
Expanded class hierarchy of TamperPluginBase
File
- src/
Tamper.php, line 236 - Contains TamperPluginBase.
View source
abstract class TamperPluginBase implements TamperPluginInterface {
/**
* The plugin id.
*
* @var string
*/
protected $pluginId;
/**
* The plugin implementation definition.
*
* @var TamperPluginDefinition
*/
protected $pluginDefinition;
/**
* Configuration information passed into the plugin.
*
* @var array
*/
protected $configuration;
/**
* Constructs a TamperPluginBase object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin id for the plugin instance.
* @param TamperPluginDefinition $plugin_definition
* The plugin implementation definition.
*/
public function __construct(array $configuration, $plugin_id, TamperPluginDefinition $plugin_definition) {
$this->pluginId = $plugin_id;
$this->pluginDefinition = $plugin_definition;
// Calling setConfiguration() ensures the configuration is clean and
// defaults are set.
$this
->setConfiguration($configuration);
}
/**
* {@inheritdoc}
*/
public function getPluginId() {
return $this->pluginId;
}
/**
* {@inheritdoc}
*/
public function getPluginDefinition() {
return $this->pluginDefinition;
}
/**
* {@inheritdoc}
*/
public function getConfiguration($key = NULL) {
if ($key === NULL) {
return $this->configuration;
}
if (isset($this->configuration[$key])) {
return $this->configuration[$key];
}
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$defaults = $this
->defaultConfiguration();
$this->configuration = array_intersect_key($configuration, $defaults) + $defaults;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, array &$form_state) {
// Validation is optional.
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, array &$form_state) {
$this
->setConfiguration($form_state['values']['tamper_configuration']);
}
/**
* {@inheritdoc}
*/
public function executeMultiple(array $values) {
foreach ($values as $delta => $value) {
$values[$delta] = $this
->execute($value);
}
return $values;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TamperPluginBase:: |
protected | property | Configuration information passed into the plugin. | |
TamperPluginBase:: |
protected | property | The plugin implementation definition. | |
TamperPluginBase:: |
protected | property | The plugin id. | |
TamperPluginBase:: |
public | function |
Executes the plugin on multiple values. Overrides TamperPluginInterface:: |
|
TamperPluginBase:: |
public | function |
Returns this plugin's configuration. Overrides TamperPluginInterface:: |
|
TamperPluginBase:: |
public | function |
Returns the definition of the plugin implementation. Overrides TamperPluginInterface:: |
|
TamperPluginBase:: |
public | function |
Returns the plugin_id of the plugin instance. Overrides TamperPluginInterface:: |
|
TamperPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides TamperPluginInterface:: |
|
TamperPluginBase:: |
public | function |
Form submission handler. Overrides TamperPluginInterface:: |
|
TamperPluginBase:: |
public | function |
Form validation handler. Overrides TamperPluginInterface:: |
|
TamperPluginBase:: |
public | function | Constructs a TamperPluginBase object. | |
TamperPluginInterface:: |
public | function | Form constructor. | 1 |
TamperPluginInterface:: |
public | function | Returns default configuration for this plugin. | 1 |
TamperPluginInterface:: |
public | function | Executes the plugin. | 1 |