By gábor hojtsy on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Introduced in version:
8.0
Issue links:
Description:
token_replace(), hook_tokens(), hook_tokens_alter() and user_mail_tokens() used to take a full language object in $options['language']. To unify this with other places, like t() and simplify the data structure, this was changed to 'langcode'.
Drupal 7:
$output = token_replace($input, array('node' => $node), array('language' => $language_interface));
function node_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array('absolute' => TRUE);
if (isset($options['language'])) {
$url_options['language'] = $options['language'];
$language_code = $options['language']->langcode;
}
else {
$language_code = NULL;
}
// ....
}
Drupal 8:
$output = token_replace($input, array('node' => $node), array('langcode' => $language_interface->langcode));
function node_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array('absolute' => TRUE);
if (isset($options['langcode'])) {
$url_options['language'] = language_load($options['langcode']);
$langcode = $options['langcode'];
}
else {
$langcode = NULL;
}
// ...
}
Impacts:
Module developers
Comments
No longer relevant
token_replace() has been replaced with a service.
see change record https://drupal.org/node/1973488 The token API is a service