protected function FilterHtml::prepareAttributeValues in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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
1 call to FilterHtml::prepareAttributeValues()
- FilterHtml::filterAttributes in core/
modules/ filter/ src/ Plugin/ Filter/ FilterHtml.php - Provides filtering of tag attributes into accepted HTML.
File
- core/
modules/ filter/ src/ Plugin/ Filter/ FilterHtml.php, line 225 - Contains \Drupal\filter\Plugin\Filter\FilterHtml.
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;
}