You are here

abstract class WordfilterProcessBase in Wordfilter 8.2

Base class for Wordfilter Process plugins.

Hierarchy

Expanded class hierarchy of WordfilterProcessBase

2 files declare their use of WordfilterProcessBase
DefaultWordfilterProcess.php in src/Plugin/WordfilterProcess/DefaultWordfilterProcess.php
TokenWordfilterProcess.php in src/Plugin/WordfilterProcess/TokenWordfilterProcess.php

File

src/Plugin/WordfilterProcessBase.php, line 13

Namespace

Drupal\wordfilter\Plugin
View source
abstract class WordfilterProcessBase extends PluginBase implements WordfilterProcessInterface {

  /**
   * Prepares the filter words for being used inside a regular expression.
   *
   * @param array $words
   *   The (not yet) prepared filter words.
   *
   * @return array
   *   The filter words, ready to be used inside a regular expression.
   */
  protected function prepareWordsForRegex(array $words) {
    $prepared = [];
    foreach ($words as $delta => $word) {
      $prepared[$delta] = preg_quote(Xss::filterAdmin($word), '/');
      if (strlen($prepared[$delta]) === strlen($word)) {

        // Use word boundaries for 'naturally spoken' words.
        $prepared[$delta] = '\\b' . $prepared[$delta] . '\\b';
      }
    }
    return $prepared;
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state, WordfilterConfigurationInterface $wordfilter_config) {
    $definition = $this
      ->getPluginDefinition();
    return [
      'description' => [
        '#markup' => '<em>' . t('Process description') . '</em>: ' . $definition['description'],
        '#weight' => 0,
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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
WordfilterProcessInterface::filterWords public function Provides filtering of words by the given Wordfilter configuration. 2