You are here

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

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\WordfilterProcess
View 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

Namesort descending Modifiers Type Description Overrides
DefaultWordfilterProcess::filterWords public function Provides filtering of words by the given Wordfilter configuration. Overrides WordfilterProcessInterface::filterWords
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92
WordfilterProcessBase::prepareWordsForRegex protected function Prepares the filter words for being used inside a regular expression.
WordfilterProcessBase::settingsForm public function Additional settings form according to the given Wordfilter configuration. Overrides WordfilterProcessInterface::settingsForm