protected function FilterHtml::prepareAttributeValues in Drupal 10
Same name and namespace in other branches
- 8 core/modules/filter/src/Plugin/Filter/FilterHtml.php \Drupal\filter\Plugin\Filter\FilterHtml::prepareAttributeValues()
- 9 core/modules/filter/src/Plugin/Filter/FilterHtml.php \Drupal\filter\Plugin\Filter\FilterHtml::prepareAttributeValues()
Helper function to prepare attribute values including wildcards.
Splits the values into two lists, one for values that must match exactly and the other for values that are wildcard prefixes.
Parameters
bool|array $attribute_values: TRUE, FALSE, or an array of allowed values.
Return value
bool|array
File
- core/
modules/ filter/ src/ Plugin/ Filter/ FilterHtml.php, line 224
Class
- FilterHtml
- Provides a filter to limit allowed HTML tags.
Namespace
Drupal\filter\Plugin\FilterCode
protected function prepareAttributeValues($attribute_values) {
if ($attribute_values === TRUE || $attribute_values === FALSE) {
return $attribute_values;
}
$result = [
'exact' => [],
'prefix' => [],
];
foreach ($attribute_values as $name => $allowed) {
// A trailing * indicates wildcard, but it must have some prefix.
if (substr($name, -1) === '*' && $name[0] !== '*') {
$result['prefix'][str_replace('*', '', $name)] = $allowed;
}
else {
$result['exact'][$name] = $allowed;
}
}
krsort($result['prefix']);
return $result;
}