Provides a base class for Filter plugins.
Expanded class hierarchy of FilterBase
abstract class FilterBase extends 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 function setPluginConfiguration(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 function export() {
return array(
'module' => $this->pluginDefinition['module'],
'status' => $this->status,
'weight' => $this->weight,
'settings' => $this->settings,
);
}
/**
* {@inheritdoc}
*/
public function getType() {
return $this->pluginDefinition['type'];
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this->pluginDefinition['title'];
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->pluginDefinition['description'];
}
/**
* {@inheritdoc}
*/
public function settingsForm(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.
return array();
}
/**
* {@inheritdoc}
*/
public function prepare($text, $langcode, $cache, $cache_id) {
return $text;
}
/**
* {@inheritdoc}
*/
public function tips($long = FALSE) {
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FilterBase:: |
protected | property | A collection of all filters this filter participates in. | |
FilterBase:: |
public | property | A Boolean indicating whether the text processed by this filter may be cached. | |
FilterBase:: |
public | property | The name of the module that owns this filter. | |
FilterBase:: |
protected | property | The plugin ID of this filter. | |
FilterBase:: |
public | property | An associative array containing the configured settings of this filter. | |
FilterBase:: |
public | property | A Boolean indicating whether this filter is enabled. | |
FilterBase:: |
public | property | The weight of this filter compared to others in a filter collection. | |
FilterBase:: |
public | function |
Exports the complete configuration of this filter plugin instance. Overrides FilterInterface:: |
|
FilterBase:: |
public | function |
Returns the administrative description for this filter plugin. Overrides FilterInterface:: |
|
FilterBase:: |
public | function |
Returns the administrative label for this filter plugin. Overrides FilterInterface:: |
|
FilterBase:: |
public | function |
Returns the processing type of this filter plugin. Overrides FilterInterface:: |
|
FilterBase:: |
public | function |
Prepares the text for processing. Overrides FilterInterface:: |
|
FilterBase:: |
public | function |
Sets the configuration for this filter plugin instance. Overrides FilterInterface:: |
|
FilterBase:: |
public | function |
Generates a filter's settings form. Overrides FilterInterface:: |
2 |
FilterBase:: |
public | function |
Generates a filter's tip. Overrides FilterInterface:: |
6 |
FilterBase:: |
public | function |
Constructs a Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
FilterInterface:: |
public | function | Performs the filter processing. | 9 |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
public | function |
Returns the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |