You are here

public function PluginBase::globalTokenForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::globalTokenForm()

Adds elements for available core tokens to a form.

Parameters

array $form: The form array to alter, passed by reference.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ViewsPluginInterface::globalTokenForm

3 calls to PluginBase::globalTokenForm()
TestExample::buildOptionsForm in core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php
Provide a form to edit options for this plugin.
Title::buildOptionsForm in core/modules/views/src/Plugin/views/area/Title.php
Provide a form to edit options for this plugin.
TokenizeAreaPluginBase::tokenForm in core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php
Adds tokenization form elements.

File

core/modules/views/src/Plugin/views/PluginBase.php, line 446
Contains \Drupal\views\Plugin\views\PluginBase.

Class

PluginBase
Base class for any views plugin types.

Namespace

Drupal\views\Plugin\views

Code

public function globalTokenForm(&$form, FormStateInterface $form_state) {
  $token_items = array();
  foreach ($this
    ->getAvailableGlobalTokens() as $type => $tokens) {
    $item = array(
      '#markup' => $type,
      'children' => array(),
    );
    foreach ($tokens as $name => $info) {
      $item['children'][$name] = "[{$type}:{$name}]" . ' - ' . $info['name'] . ': ' . $info['description'];
    }
    $token_items[$type] = $item;
  }
  $form['global_tokens'] = array(
    '#type' => 'details',
    '#title' => $this
      ->t('Available global token replacements'),
  );
  $form['global_tokens']['list'] = array(
    '#theme' => 'item_list',
    '#items' => $token_items,
    '#attributes' => array(
      'class' => array(
        'global-tokens',
      ),
    ),
  );
}