You are here

function disable_link_rel_link_alter in Disable link rel 8

Implements hook_link_alter().

File

./disable_link_rel.module, line 72
The main functionality of the module. Getting data and using it in hooks.

Code

function disable_link_rel_link_alter(&$variables) {
  $config = \Drupal::getContainer()
    ->get('config.factory')
    ->getEditable('disable_link_rel.import');
  $enable = $config
    ->get('remove_link_attr', FALSE);
  if ($enable) {
    $unset_attr_list = _disable_link_rel_parse_values($config
      ->get('remove_link_attr_list', ''));
    foreach ($unset_attr_list as $attr) {
      if (array_key_exists($attr, $variables['options']['attributes'])) {
        unset($variables['options']['attributes'][$attr]);
      }
    }
  }
}