You are here

function ArgumentPluginBase::get_value in Views (for Drupal 7) 8.3

Get the value of this argument.

File

lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php, line 990
Definition of Drupal\views\Plugin\views\argument\ArgumentPluginBase.

Class

ArgumentPluginBase
Base class for arguments.

Namespace

Drupal\views\Plugin\views\argument

Code

function get_value() {

  // If we already processed this argument, we're done.
  if (isset($this->argument)) {
    return $this->argument;
  }

  // Otherwise, we have to pretend to process ourself 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 = isset($this->view->args[$position]) ? $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
    ->has_default_argument()) {
    $arg = $argument
      ->get_default_argument();

    // 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
    ->set_argument($arg)) {
    $value = $argument->argument;
  }
  unset($argument);
  return $value;
}