function UserTokensHooks::tokenInfo

Implements hook_token_info().

Attributes

#[Hook('token_info')]

File

core/modules/user/src/Hook/UserTokensHooks.php, line 21

Class

UserTokensHooks
Hook implementations for user.

Namespace

Drupal\user\Hook

Code

public function tokenInfo() : array {
  $types['user'] = [
    'name' => $this->t('Users'),
    'description' => $this->t('Tokens related to individual user accounts.'),
    'needs-data' => 'user',
  ];
  $types['current-user'] = [
    'name' => $this->t('Current user'),
    'description' => $this->t('Tokens related to the currently logged in user.'),
    'type' => 'user',
  ];
  $user['uid'] = [
    'name' => $this->t('User ID'),
    'description' => $this->t("The unique ID of the user account."),
  ];
  $user['uuid'] = [
    'name' => $this->t('UUID'),
    'description' => $this->t("The UUID of the user account."),
  ];
  $user['name'] = [
    'name' => $this->t("Deprecated: User Name"),
    'description' => $this->t("Deprecated: Use account-name or display-name instead."),
  ];
  $user['account-name'] = [
    'name' => $this->t("Account Name"),
    'description' => $this->t("The login name of the user account."),
  ];
  $user['display-name'] = [
    'name' => $this->t("Display Name"),
    'description' => $this->t("The display name of the user account."),
  ];
  $user['mail'] = [
    'name' => $this->t("Email"),
    'description' => $this->t("The email address of the user account."),
  ];
  $user['url'] = [
    'name' => $this->t("URL"),
    'description' => $this->t("The URL of the account profile page."),
  ];
  $user['edit-url'] = [
    'name' => $this->t("Edit URL"),
    'description' => $this->t("The URL of the account edit page."),
  ];
  $user['last-login'] = [
    'name' => $this->t("Last login"),
    'description' => $this->t("The date the user last logged in to the site."),
    'type' => 'date',
  ];
  $user['created'] = [
    'name' => $this->t("Created"),
    'description' => $this->t("The date the user account was created."),
    'type' => 'date',
  ];
  return [
    'types' => $types,
    'tokens' => [
      'user' => $user,
    ],
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.