treeBuilder = $tree_builder; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('token.tree_builder') ); } /** * Page callback to output a token tree as an empty page. */ function outputTree(Request $request) { $options = $request->query->has('options') ? Json::decode($request->query->get('options')) : []; // The option token_types may only be an array OR 'all'. If it is not set, // we assume that only global token types are requested. $token_types = !empty($options['token_types']) ? $options['token_types'] : []; if ($token_types == 'all') { $build = $this->treeBuilder->buildAllRenderable($options); } else { $build = $this->treeBuilder->buildRenderable($token_types, $options); } $build['#cache']['contexts'][] = 'url.query_args:options'; $build['#title'] = $this->t('Available tokens'); return $build; } }