function ArgumentPluginBase::getTokenHelp

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getTokenHelp()
  2. 8.9.x core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getTokenHelp()
  3. 11.x 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 435

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) $this->t('Arguments')]["{{ arguments.{$arg} }}"] = $this->t('@argument title', [
            '@argument' => $handler->adminLabel(),
        ]);
        $options[(string) $this->t('Arguments')]["{{ raw_arguments.{$arg} }}"] = $this->t('@argument input', [
            '@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 = [];
                foreach ($options[$type] as $key => $value) {
                    $items[] = $key . ' == ' . $value;
                }
                $item_list = [
                    '#theme' => 'item_list',
                    '#items' => $items,
                ];
                $output[] = $item_list;
            }
        }
    }
    return $output;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.