FilterHtmlEscape.php

Same filename and directory in other branches
  1. 9 core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php
  2. 8.9.x core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php
  3. 10 core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php

Namespace

Drupal\filter\Plugin\Filter

File

core/modules/filter/src/Plugin/Filter/FilterHtmlEscape.php

View source
<?php

namespace Drupal\filter\Plugin\Filter;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\filter\Attribute\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
use Drupal\filter\Plugin\FilterInterface;

/**
 * Provides a filter to display any HTML as plain text.
 */
class FilterHtmlEscape extends FilterBase {
  
  /**
   * {@inheritdoc}
   */
  public function process($text, $langcode) {
    return new FilterProcessResult(_filter_html_escape($text));
  }
  
  /**
   * {@inheritdoc}
   */
  public function getHTMLRestrictions() {
    // Nothing is allowed.
    return [
      'allowed' => [],
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function tips($long = FALSE) {
    return $this->t('No HTML tags allowed.');
  }

}

Classes

Title Deprecated Summary
FilterHtmlEscape Provides a filter to display any HTML as plain text.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.