function ArgumentPluginBase::getValue

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getValue()
  2. 8.9.x core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getValue()
  3. 10 core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getValue()

Get the value of this argument.

File

core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php, line 1108

Class

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

Namespace

Drupal\views\Plugin\views\argument

Code

public function getValue() {
    // If we already processed this argument, we're done.
    if (isset($this->argument)) {
        return $this->argument;
    }
    // Otherwise, we have to pretend to process ourselves to find the value.
    $value = NULL;
    // Find the position of this argument within the view.
    $position = 0;
    foreach ($this->view->argument as $id => $argument) {
        if ($id == $this->options['id']) {
            break;
        }
        $position++;
    }
    $arg = $this->view->args[$position] ?? NULL;
    $this->position = $position;
    // Clone ourselves so that we don't break things when we're really
    // processing the arguments.
    $argument = clone $this;
    if (!isset($arg) && $argument->hasDefaultArgument()) {
        $arg = $argument->getDefaultArgument();
        // Remember that this argument was computed, not passed on the URL.
        $this->is_default = TRUE;
    }
    // Set the argument, which will also validate that the argument can be set.
    if ($argument->setArgument($arg)) {
        $value = $argument->argument;
    }
    unset($argument);
    return $value;
}

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