You are here

public function FilterTestRestrictTagsAndAttributes::process in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestRestrictTagsAndAttributes.php \Drupal\filter_test\Plugin\Filter\FilterTestRestrictTagsAndAttributes::process()

Performs the filter processing.

Parameters

string $text: The text string to be filtered.

string $langcode: The language code of the text to be filtered.

Return value

\Drupal\filter\FilterProcessResult The filtered text, wrapped in a FilterProcessResult object, and possibly with associated assets, cacheability metadata and placeholders.

Overrides FilterInterface::process

See also

\Drupal\filter\FilterProcessResult

File

core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestRestrictTagsAndAttributes.php, line 24

Class

FilterTestRestrictTagsAndAttributes
Provides a test filter to restrict HTML tags and attributes.

Namespace

Drupal\filter_test\Plugin\Filter

Code

public function process($text, $langcode) {
  $allowed_tags = array_filter($this->settings['restrictions']['allowed'], function ($value) {
    return is_array($value) || (bool) $value !== FALSE;
  });
  return new FilterProcessResult(Xss::filter($text, array_keys($allowed_tags)));
}