language_cookie_test.module in Language Cookie 8
Module for language_cookie testing.
File
tests/modules/language_cookie_test/language_cookie_test.moduleView source
<?php
/**
* @file
* Module for language_cookie testing.
*/
/**
* Implements hook_page_top().
*/
function language_cookie_test_page_top() {
if (\Drupal::moduleHandler()
->moduleExists('language')) {
language_cookie_test_store_language_negotiation();
}
}
/**
* Store the last negotiated languages.
*/
function language_cookie_test_store_language_negotiation() {
$last = [];
foreach (\Drupal::languageManager()
->getDefinedLanguageTypes() as $type) {
$last[$type] = \Drupal::languageManager()
->getCurrentLanguage($type)
->getId();
}
\Drupal::state()
->set('language_cookie_test.language_negotiation_last', $last);
}
Functions
Name | Description |
---|---|
language_cookie_test_page_top | Implements hook_page_top(). |
language_cookie_test_store_language_negotiation | Store the last negotiated languages. |