function FilterHtml::findAllowedValue

Same name and namespace in other branches
  1. 11.x 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

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;
}

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