TokenTreeBrowseController.php in Token 8
File
tests/modules/token_module_test/src/Controller/TokenTreeBrowseController.php
View source
<?php
namespace Drupal\token_module_test\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Request;
use Drupal\token\TokenInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TokenTreeBrowseController extends ControllerBase {
protected $token;
public function __construct(TokenInterface $token) {
$this->token = $token;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('token'));
}
public function outputLink(Request $request) {
$build['tree']['#theme'] = 'token_tree_link';
$build['tokenarea'] = [
'#markup' => $this->token
->replace('[current-page:title]'),
'#type' => 'markup',
];
return $build;
}
public function getTitle() {
return [
'#type' => 'markup',
'#markup' => 'Available Tokens',
];
}
}