You are here

function languageicons_language_switch_links_alter in Language Icons 8

Same name and namespace in other branches
  1. 7 languageicons.module \languageicons_language_switch_links_alter()

Implements hook_language_switch_links_alter().

Adds language icons to language switcher block links.

@todo Figure out a way to either ignore node links or specifically target them here. See http://drupal.org/node/1005144 for more info.

File

./languageicons.module, line 59
Main functions and hook implementations for the Language Icons module.

Code

function languageicons_language_switch_links_alter(array &$links, $type, $path) {
  if (\Drupal::config('languageicons.settings')
    ->get('show_block') || \Drupal::config('languageicons.settings')
    ->get('show_node')) {
    foreach (array_keys($links) as $langcode) {
      if (!isset($links[$langcode]['language'])) {
        $links[$langcode]['language'] = \Drupal::languageManager()
          ->getLanguage($langcode);
      }
      languageicons_link_add($links[$langcode]);
    }
  }
}