You are here

protected function FilterHtml::findAllowedValue in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/filter/src/Plugin/Filter/FilterHtml.php \Drupal\filter\Plugin\Filter\FilterHtml::findAllowedValue()
  2. 10 core/modules/filter/src/Plugin/Filter/FilterHtml.php \Drupal\filter\Plugin\Filter\FilterHtml::findAllowedValue()

Helper function to handle prefix matching.

Parameters

array $allowed: Array of allowed names and prefixes.

string $name: The name to find or match against a prefix.

Return value

bool|array

1 call to FilterHtml::findAllowedValue()
FilterHtml::filterElementAttributes in core/modules/filter/src/Plugin/Filter/FilterHtml.php
Filters attributes on an element according to a list of allowed values.

File

core/modules/filter/src/Plugin/Filter/FilterHtml.php, line 200

Class

FilterHtml
Provides a filter to limit allowed HTML tags.

Namespace

Drupal\filter\Plugin\Filter

Code

protected function findAllowedValue(array $allowed, $name) {
  if (isset($allowed['exact'][$name])) {
    return $allowed['exact'][$name];
  }

  // Handle prefix (wildcard) matches.
  foreach ($allowed['prefix'] as $prefix => $value) {
    if (strpos($name, $prefix) === 0) {
      return $value;
    }
  }
  return FALSE;
}