public function Raw::getArgument in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/src/Plugin/views/argument_default/Raw.php \Drupal\views\Plugin\views\argument_default\Raw::getArgument()
Return the default argument.
This needs to be overridden by every default argument handler to properly do what is needed.
Overrides ArgumentDefaultPluginBase::getArgument
File
- core/
modules/ views/ src/ Plugin/ views/ argument_default/ Raw.php, line 115
Class
- Raw
- Default argument plugin to use the raw value from the URL.
Namespace
Drupal\views\Plugin\views\argument_defaultCode
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']];
}
}