diff --git a/src/Controller/AvailableTokens.php b/src/Controller/AvailableTokens.php new file mode 100644 index 0000000..ded1061 --- /dev/null +++ b/src/Controller/AvailableTokens.php @@ -0,0 +1,22 @@ +buildAllRenderable([ + 'click_insert' => FALSE, + 'show_restricted' => TRUE, + 'show_nested' => FALSE, + ]); + + $output .= t('The list of the currently available tokens on this site are shown below'); + $output .= \Drupal::service('renderer')->render($token_tree); + return array( + '#markup' => $output, + ); + } +} diff --git a/token.module b/token.module index 0b837e4..611ecce 100644 --- a/token.module +++ b/token.module @@ -5,6 +5,7 @@ * Enhances the token API in core: adds a browseable UI, missing tokens, etc. */ +use Drupal\Core\Link; use Drupal\Component\Render\PlainTextOutput; use Drupal\Component\Utility\Unicode; use Drupal\Core\Block\BlockPluginInterface; @@ -29,13 +30,15 @@ function token_help($route_name, RouteMatchInterface $route_match) { 'show_restricted' => TRUE, 'show_nested' => FALSE, ]); + + $edit_link = Link::createFromRoute(t('Here'), 'token.reports'); $output = '

' . t('About') . '

'; $output .= '

' . t('The Token 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 online documentation.', [':online' => 'https://www.drupal.org/documentation/modules/token', ':project' => 'https://www.drupal.org/project/token']) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '

' . 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.') . '

'; $output .= '
'; - $output .= '
' . t('The list of the currently available tokens on this site are shown below.') . '
'; - $output .= '
' . \Drupal::service('renderer')->render($token_tree) . '
'; + $output .= '
' . t('The list of the currently available tokens on this site are shown.') . '
'; + $output .= $edit_link->toString(); $output .= '
'; return $output; } diff --git a/token.routing.yml b/token.routing.yml index f2105ae..a6880bb 100644 --- a/token.routing.yml +++ b/token.routing.yml @@ -20,3 +20,10 @@ token.flush_cache: _permission: 'flush caches' _csrf_token: 'TRUE' _module_dependencies: 'admin_menu' + +token.reports: + path: '/admin/reports/tokens' + defaults: + _controller: '\Drupal\token\Controller\AvailableTokens::content' + requirements: + _permission: 'access content'