You are here

language_cookie.api.php in Language Cookie 8

Documentation for Language Cookie module APIs.

File

language_cookie.api.php
View source
<?php

/**
 * @file
 * Documentation for Language Cookie module APIs.
 */
use Symfony\Component\HttpFoundation\Cookie;

/**
 * @addtogroup hooks
 * @{
 */

/**
 * Modify the list of available Language Cookie condition plugins.
 *
 * This hook may be used to modify plugin properties after they have been
 * specified by other modules.
 *
 * @param array &$plugins
 *   An array of all the existing plugin definitions, passed by reference.
 *
 * @see \Drupal\language_cookie\LanguageCookieConditionManager
 */
function hook_language_cookie_condition_info_alter(array &$plugins) {
  $plugins['someplugin']['name'] = t('Better name');
}

/**
 * Modify the langage cookie that is set by this module.
 *
 * @param \Symfony\Component\HttpFoundation\Cookie &$cookie
 *   The actual cookie, passed by reference.
 *
 * @see \Drupal\language_cookie\EventSubscriber\LanguageCookieSubscriber::setLanguageCookie()
 */
function hook_language_cookie_alter(Cookie &$cookie) {
  $default_langcode = \Drupal::languageManager()
    ->getCurrentLanguage()
    ->getId();
  $cookie = new Cookie('my_altered_language_cookie', $default_langcode);
}

/**
 * @} End of "addtogroup hooks".
 */

Functions

Namesort descending Description
hook_language_cookie_alter Modify the langage cookie that is set by this module.
hook_language_cookie_condition_info_alter Modify the list of available Language Cookie condition plugins.