You are here

protected function ArgumentPluginBase::getTokenHelp in Zircon Profile 8

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

Provide token help information for the argument.

Return value

array A render array.

1 call to ArgumentPluginBase::getTokenHelp()
ArgumentPluginBase::buildOptionsForm in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
Provide a form to edit options for this plugin.

File

core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php, line 373
Contains \Drupal\views\Plugin\views\argument\ArgumentPluginBase.

Class

ArgumentPluginBase
Base class for argument (contextual filter) handler plugins.

Namespace

Drupal\views\Plugin\views\argument

Code

protected function getTokenHelp() {
  $output = [];
  foreach ($this->view->display_handler
    ->getHandlers('argument') as $arg => $handler) {

    /** @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase $handler */
    $options[(string) t('Arguments')]["{{ arguments.{$arg} }}"] = $this
      ->t('@argument title', array(
      '@argument' => $handler
        ->adminLabel(),
    ));
    $options[(string) t('Arguments')]["{{ raw_arguments.{$arg} }}"] = $this
      ->t('@argument input', array(
      '@argument' => $handler
        ->adminLabel(),
    ));
  }

  // We have some options, so make a list.
  if (!empty($options)) {
    $output[] = [
      '#markup' => '<p>' . $this
        ->t("The following replacement tokens are available for this argument.") . '</p>',
    ];
    foreach (array_keys($options) as $type) {
      if (!empty($options[$type])) {
        $items = array();
        foreach ($options[$type] as $key => $value) {
          $items[] = $key . ' == ' . $value;
        }
        $item_list = array(
          '#theme' => 'item_list',
          '#items' => $items,
        );
        $output[] = $item_list;
      }
    }
  }
  return $output;
}