Change record status: 
Project: 
Introduced in branch: 
8.8.x
Introduced in version: 
Description: 

Summary

  • Creating the token timezone for the current user
  • Creating tests for this feature
  • Reference this token in the help page of this module (admin/help/token)

code added

public function testUserTokenReplacement() {
  $metadata_tests['[user:timezone]'] = $base_bubbleable_metadata;
}

public function testUserTokenReplacement() {
  $metadata_tests['[current-user:timezone]'] = $base_bubbleable_metadata->merge(BubbleableMetadata::createFromObject($global_account)->addCacheContexts(['user']));
}

function user_token_info() {
  $user['timezone'] = [
      'name' => t("Timezone"),
      'description' => t("The timezone of the current user account."),
  ];
}

function user_tokens() {
  case 'timezone':
    // Fallback to system default timezone, as timestamps are localised.
    $replacements[$original] = $account->getTimeZone() ?: date_default_timezone_get();
    break;
}
Impacts: 
Site builders, administrators, editors