function Raw::getArgument

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/argument_default/Raw.php \Drupal\views\Plugin\views\argument_default\Raw::getArgument()
  2. 8.9.x core/modules/views/src/Plugin/views/argument_default/Raw.php \Drupal\views\Plugin\views\argument_default\Raw::getArgument()
  3. 11.x core/modules/views/src/Plugin/views/argument_default/Raw.php \Drupal\views\Plugin\views\argument_default\Raw::getArgument()

Overrides ArgumentDefaultPluginBase::getArgument

File

core/modules/views/src/Plugin/views/argument_default/Raw.php, line 110

Class

Raw
Default argument plugin to use the raw value from the URL.

Namespace

Drupal\views\Plugin\views\argument_default

Code

public function getArgument() {
    // Don't trim the leading slash since getAliasByPath() requires it.
    $path = rtrim($this->currentPath
        ->getPath($this->view
        ->getRequest()), '/');
    if ($this->options['use_alias']) {
        $path = $this->aliasManager
            ->getAliasByPath($path);
    }
    $args = explode('/', $path);
    // Drop the empty first element created by the leading slash since the path
    // component index doesn't take it into account.
    array_shift($args);
    if (isset($args[$this->options['index']])) {
        return $args[$this->options['index']];
    }
}

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