abstract class FilterBase

Provides a base class for Filter plugins.

Hierarchy

Expanded class hierarchy of FilterBase

9 files declare their use of FilterBase
FilterAutoP.php in drupal/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterAutoP.php
Contains \Drupal\filter\Plugin\Filter\FilterAutoP.
FilterHtml.php in drupal/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php
Contains \Drupal\filter\Plugin\Filter\FilterHtml.
FilterHtmlCorrector.php in drupal/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlCorrector.php
Contains \Drupal\filter\Plugin\Filter\FilterHtmlCorrector.
FilterHtmlEscape.php in drupal/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlEscape.php
Contains \Drupal\filter\Plugin\Filter\FilterHtmlEscape.
FilterHtmlImageSecure.php in drupal/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlImageSecure.php
Contains \Drupal\filter\Plugin\Filter\FilterHtmlImageSecure.

... See full list

File

drupal/core/modules/filter/lib/Drupal/filter/Plugin/FilterBase.php, line 17
Contains \Drupal\filter\Plugin\Filter\FilterBase.

Namespace

Drupal\filter\Plugin
View source
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) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FilterBase::$bag protected property A collection of all filters this filter participates in.
FilterBase::$cache public property A Boolean indicating whether the text processed by this filter may be cached.
FilterBase::$module public property The name of the module that owns this filter.
FilterBase::$plugin_id protected property The plugin ID of this filter.
FilterBase::$settings public property An associative array containing the configured settings of this filter.
FilterBase::$status public property A Boolean indicating whether this filter is enabled.
FilterBase::$weight public property The weight of this filter compared to others in a filter collection.
FilterBase::export public function Exports the complete configuration of this filter plugin instance. Overrides FilterInterface::export
FilterBase::getDescription public function Returns the administrative description for this filter plugin. Overrides FilterInterface::getDescription
FilterBase::getLabel public function Returns the administrative label for this filter plugin. Overrides FilterInterface::getLabel
FilterBase::getType public function Returns the processing type of this filter plugin. Overrides FilterInterface::getType
FilterBase::prepare public function Prepares the text for processing. Overrides FilterInterface::prepare
FilterBase::setPluginConfiguration public function Sets the configuration for this filter plugin instance. Overrides FilterInterface::setPluginConfiguration
FilterBase::settingsForm public function Generates a filter's settings form. Overrides FilterInterface::settingsForm 2
FilterBase::tips public function Generates a filter's tip. Overrides FilterInterface::tips 6
FilterBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct
FilterInterface::process public function Performs the filter processing. 9
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::getPluginDefinition public function Returns the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId