function ViewsSelection::stripAdminAndAnchorTagsFromResults
Same name in other branches
- 8.9.x core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::stripAdminAndAnchorTagsFromResults()
- 10 core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::stripAdminAndAnchorTagsFromResults()
- 11.x core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::stripAdminAndAnchorTagsFromResults()
Strips all admin and anchor tags from a result list.
These results are usually displayed in an autocomplete field, which is surrounded by anchor tags. Most tags are allowed inside anchor tags, except for other anchor tags.
Parameters
array $results: The result list.
Return value
array The provided result list with anchor tags removed.
1 call to ViewsSelection::stripAdminAndAnchorTagsFromResults()
- ViewsSelection::getReferenceableEntities in core/
modules/ views/ src/ Plugin/ EntityReferenceSelection/ ViewsSelection.php - Gets the list of referenceable entities.
File
-
core/
modules/ views/ src/ Plugin/ EntityReferenceSelection/ ViewsSelection.php, line 280
Class
- ViewsSelection
- Plugin implementation of the 'selection' entity_reference.
Namespace
Drupal\views\Plugin\EntityReferenceSelectionCode
protected function stripAdminAndAnchorTagsFromResults(array $results) {
$allowed_tags = Xss::getAdminTagList();
if (($key = array_search('a', $allowed_tags)) !== FALSE) {
unset($allowed_tags[$key]);
}
$stripped_results = [];
foreach (Element::children($results) as $id) {
$entity = $results[$id]['#row']->_entity;
$stripped_results[$entity->bundle()][$id] = ViewsRenderPipelineMarkup::create(Xss::filter($this->renderer
->renderPlain($results[$id]), $allowed_tags));
}
return $stripped_results;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.