You are here

public function Raw::getArgument in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/argument_default/Raw.php \Drupal\views\Plugin\views\argument_default\Raw::getArgument()
  2. 9 core/modules/views/src/Plugin/views/argument_default/Raw.php \Drupal\views\Plugin\views\argument_default\Raw::getArgument()

File

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

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']];
  }
}