function token_help in Token 8
Same name and namespace in other branches
- 5 token.module \token_help()
- 6 token.module \token_help()
- 7 token.module \token_help()
Implements hook_help().
File
- ./
token.module, line 26 - Enhances the token API in core: adds a browseable UI, missing tokens, etc.
Code
function token_help($route_name, RouteMatchInterface $route_match) {
if ($route_name == 'help.page.token') {
$token_tree = \Drupal::service('token.tree_builder')
->buildAllRenderable([
'click_insert' => FALSE,
'show_restricted' => TRUE,
'show_nested' => FALSE,
]);
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The <a href=":project">Token</a> module provides a user interface for the site token system. It also adds some additional tokens that are used extensively during site development. Tokens are specially formatted chunks of text that serve as placeholders for a dynamically generated value. For more information, covering both the token system and the additional tools provided by the Token module, see the <a href=":online">online documentation</a>.', [
':online' => 'https://www.drupal.org/documentation/modules/token',
':project' => 'https://www.drupal.org/project/token',
]) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<p>' . t('Your website uses a shared token system for exposing and using placeholder tokens and their appropriate replacement values. This allows for any module to provide placeholder tokens for strings without having to reinvent the wheel. It also ensures consistency in the syntax used for tokens, making the system as a whole easier for end users to use.') . '</p>';
$output .= '<dl>';
$output .= '<dt>' . t('The list of the currently available tokens on this site are shown below.') . '</dt>';
$output .= '<dd>' . \Drupal::service('renderer')
->render($token_tree) . '</dd>';
$output .= '</dl>';
return $output;
}
}