9b2ba08639bf18ad515ef98bc55b19a9ff005ebf
[yaffs-website] / web / modules / contrib / token / tests / modules / token_module_test / src / Controller / TokenTreeBrowseController.php
1 <?php
2
3 namespace Drupal\token_module_test\Controller;
4
5 use Drupal\Core\Controller\ControllerBase;
6 use Symfony\Component\HttpFoundation\Request;
7
8 class TokenTreeBrowseController extends ControllerBase {
9
10   /**
11    * Page callback to output a link.
12    */
13   function outputLink(Request $request) {
14     $build['tree']['#theme'] = 'token_tree_link';
15     $build['tokenarea'] = [
16       '#markup' => \Drupal::token()->replace('[current-page:title]'),
17       '#type' => 'markup',
18     ];
19     return $build;
20   }
21
22   /**
23    * Title callback for the page outputting a link.
24    *
25    * We are using a title callback instead of directly defining the title in the
26    * routing YML file. This is so that we could return an array instead of a
27    * simple string. This allows us to test if [current-page:title] works with
28    * render arrays and other objects as titles.
29    */
30   public function getTitle() {
31     return [
32       '#type' => 'markup',
33       '#markup' => 'Available Tokens',
34     ];
35   }
36
37 }