You are here

public function BrowseTokens::tokenBrowser in Views Token Argument 8

Same name and namespace in other branches
  1. 2.0.x src/BrowseTokens.php \Drupal\views_argument_token\BrowseTokens::tokenBrowser()

Gatekeeper function to direct to either the core or contributed Token.

Return value

array If token module is installed, a popup browser plus a help text. If not only the help text.

File

src/BrowseTokens.php, line 63

Class

BrowseTokens
Token handling service. Uses core token service or contributed Token.

Namespace

Drupal\views_argument_token

Code

public function tokenBrowser() {
  $form = array();
  $form['intro_text'] = array(
    '#markup' => '<p>' . t('Configure the Token argument. Use tokens to avoid redundant data. For example, a \'keyword\' value of "example" will be shown on all content using this configuration, whereas using the [node:title] automatically inserts the "keywords" values from the current entity (node, term, etc).') . '</p>',
  );
  if ($this->moduleHandler
    ->moduleExists('token')) {
    $form['tokens'] = array(
      '#theme' => 'token_tree_link',
      '#token_types' => 'all',
      '#global_types' => TRUE,
      '#click_insert' => TRUE,
      '#show_restricted' => FALSE,
      '#recursion_limit' => 3,
      '#text' => t('Browse available tokens'),
    );
  }
  return $form;
}