diff --git a/src/Controller/TokenAvailableTokensController.php b/src/Controller/TokenAvailableTokensController.php new file mode 100644 index 0000000..2908f86 --- /dev/null +++ b/src/Controller/TokenAvailableTokensController.php @@ -0,0 +1,27 @@ +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 6470a25..0b30104 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\Url; use Drupal\Component\Render\PlainTextOutput; use Drupal\Component\Utility\Unicode; use Drupal\Core\Block\BlockPluginInterface; @@ -36,8 +37,7 @@ function token_help($route_name, RouteMatchInterface $route_match) { $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('You can also see the list of currently available tokens on the site.', array(':url' => Url::fromRoute('token.reports')->toString())) . '
'; $output .= '
'; return $output; } diff --git a/token.routing.yml b/token.routing.yml index f2105ae..455071d 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\TokenAvailableTokensController::content' + requirements: + _permission: 'administer token'