public function PluginBase::getAvailableGlobalTokens

Returns an array of available token replacements.

Parameters

bool $prepared: Whether to return the raw token info for each token or an array of prepared tokens for each type. E.g. "[view:name]".

array $types: An array of additional token types to return, defaults to 'site' and 'view'.

Return value

array An array of available token replacement info or tokens, grouped by type.

1 call to PluginBase::getAvailableGlobalTokens()
PluginBase::globalTokenForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php
Adds elements for available core tokens to a form.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php, line 258
Definition of Drupal\views\Plugin\views\PluginBase.

Class

PluginBase

Namespace

Drupal\views\Plugin\views

Code

public function getAvailableGlobalTokens($prepared = FALSE, array $types = array()) {
  $info = token_info();

  // Site and view tokens should always be available.
  $types += array(
    'site',
    'view',
  );
  $available = array_intersect_key($info['tokens'], array_flip($types));

  // Construct the token string for each token.
  if ($prepared) {
    $prepared = array();
    foreach ($available as $type => $tokens) {
      foreach (array_keys($tokens) as $token) {
        $prepared[$type][] = "[{$type}:{$token}]";
      }
    }
    return $prepared;
  }
  return $available;
}