class DefaultWordfilterProcess in Wordfilter 8.2
Plugin annotation
@WordfilterProcess(
id = "default",
label = @Translation("Direct substitution (default)"),
description = @Translation("All specified filter words will be directly replaced with the specified substitution text by using a simple and automatically generated regular expression."),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\wordfilter\Plugin\WordfilterProcessBase implements WordfilterProcessInterface
- class \Drupal\wordfilter\Plugin\WordfilterProcess\DefaultWordfilterProcess
- class \Drupal\wordfilter\Plugin\WordfilterProcessBase implements WordfilterProcessInterface
Expanded class hierarchy of DefaultWordfilterProcess
2 files declare their use of DefaultWordfilterProcess
- DefaultWordfilterProcessUnitTest.php in tests/
src/ Unit/ DefaultWordfilterProcessUnitTest.php - WordfilterConfigurationUnitTest.php in tests/
src/ Unit/ WordfilterConfigurationUnitTest.php
File
- src/
Plugin/ WordfilterProcess/ DefaultWordfilterProcess.php, line 17
Namespace
Drupal\wordfilter\Plugin\WordfilterProcessView source
class DefaultWordfilterProcess extends WordfilterProcessBase {
/**
* {@inheritdoc}
*/
public function filterWords($text, WordfilterConfigurationInterface $wordfilter_config, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED) {
foreach ($wordfilter_config
->getItems() as $item) {
$filter_words = $item
->getFilterWords();
$filter_words = $this
->prepareWordsForRegex($filter_words);
$filter_pattern = '/' . implode('|', $filter_words) . '/i';
$substitute = Xss::filterAdmin($item
->getSubstitute());
$text = preg_replace($filter_pattern, $substitute, $text);
}
return $text;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultWordfilterProcess:: |
public | function |
Provides filtering of words by the given Wordfilter configuration. Overrides WordfilterProcessInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
WordfilterProcessBase:: |
protected | function | Prepares the filter words for being used inside a regular expression. | |
WordfilterProcessBase:: |
public | function |
Additional settings form according to the given Wordfilter configuration. Overrides WordfilterProcessInterface:: |