<?php/**
* @file
* Contains \Drupal\filter\Plugin\Filter\FilterBase.
*/namespaceDrupal\filter\Plugin;
useDrupal\Component\Plugin\PluginBase;
useDrupal\Component\Plugin\Discovery\DiscoveryInterface;
useDrupal\filter\FilterBag;
/**
* Provides a base class for Filter plugins.
*/
abstract class FilterBaseextends PluginBase implements FilterInterface {
/**
* The plugin ID of this filter.
*
* @var string
*/
protected $plugin_id;
/**
* The name of the module that owns this filter.
*
* @var string
*/
public $module;
/**
* A Boolean indicating whether this filter is enabled.
*
* @var bool
*/
public $status = FALSE;
/**
* The weight of this filter compared to others in a filter collection.
*
* @see FilterBase::$filterBag
*
* @var int
*/
public $weight = 0;
/**
* A Boolean indicating whether the text processed by this filter may be cached.
*
* @var bool
*/
public $cache = TRUE;
/**
* An associative array containing the configured settings of this filter.
*
* @var array
*/
public $settings = array();
/**
* A collection of all filters this filter participates in.
*
* @var \Drupal\filter\FilterBag
*/
protected $bag;
/**
* {@inheritdoc}
*/
public function__construct(array $configuration, $plugin_id, array $plugin_definition, FilterBag $bag) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->module = $this->pluginDefinition['module'];
$this->cache = $this->pluginDefinition['cache'];
$this
->setPluginConfiguration($configuration);
$this->bag = $bag;
}
/**
* {@inheritdoc}
*/
public functionsetPluginConfiguration(array $configuration) {
if (isset($configuration['status'])) {
$this->status = (bool) $configuration['status'];
}
if (isset($configuration['weight'])) {
$this->weight = (int) $configuration['weight'];
}
if (isset($configuration['settings'])) {
$this->settings = (array) $configuration['settings'];
}
return$this;
}
/**
* {@inheritdoc}
*/
public functionexport() {
returnarray(
'module' => $this->pluginDefinition['module'],
'status' => $this->status,
'weight' => $this->weight,
'settings' => $this->settings,
);
}
/**
* {@inheritdoc}
*/
public functiongetType() {
return$this->pluginDefinition['type'];
}
/**
* {@inheritdoc}
*/
public functiongetLabel() {
return$this->pluginDefinition['title'];
}
/**
* {@inheritdoc}
*/
public functiongetDescription() {
return$this->pluginDefinition['description'];
}
/**
* {@inheritdoc}
*/
public functionsettingsForm(array $form, array &$form_state) {
// Implementations should work with and return $form. Returning an empty
// array here allows the text format administration form to identify whether
// the filter plugin has any settings form elements.returnarray();
}
/**
* {@inheritdoc}
*/
public functionprepare($text, $langcode, $cache, $cache_id) {
return$text;
}
/**
* {@inheritdoc}
*/
public functiontips($long = FALSE) {
}
}