Drupal 8 implementation of hook_language_switch_links_alter that replaces links in language switcher block with links to front page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\Core\Language\LanguageInterface; | |
use Drupal\Core\Url; | |
/** | |
* Implements hook_language_switch_links_alter(). | |
* | |
* Replaces links in language switcher block with links to front page. | |
*/ | |
function MYMODULE_language_switch_links_alter(array &$links, $type, $path) { | |
if ($type == LanguageInterface::TYPE_INTERFACE) { | |
$front = new Url('<front>'); | |
foreach ($links as &$link) { | |
$link['url'] = $front; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment