function _remove_header_links in Disable link rel 8
Remove links.
Parameters
array $attachments: Array build.
2 calls to _remove_header_links()
- disable_link_rel_entity_view_alter in ./
disable_link_rel.module - Implements hook_entity_view_alter().
- disable_link_rel_page_attachments_alter in ./
disable_link_rel.module - Implements hook_page_attachments_alter().
File
- ./
disable_link_rel.module, line 29 - The main functionality of the module. Getting data and using it in hooks.
Code
function _remove_header_links(array &$attachments) {
$config = \Drupal::getContainer()
->get('config.factory')
->getEditable('disable_link_rel.import');
$enable = $config
->get('enable', FALSE);
if ($enable) {
if (!isset($attachments['#attached']['html_head_link'])) {
return;
}
$unset_html_head_links = _disable_link_rel_parse_values($config
->get('links', ''));
foreach ($attachments['#attached']['html_head_link'] as $key => $value) {
if (isset($value[0]['rel']) && in_array($value[0]['rel'], $unset_html_head_links)) {
unset($attachments['#attached']['html_head_link'][$key]);
}
}
}
}