You are here

public function Session::getArgument in Views Extras (Session/Cookie/Token Support) 8

Same name and namespace in other branches
  1. 2.x src/Plugin/views/argument_default/Session.php \Drupal\views_extras\Plugin\views\argument_default\Session::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

src/Plugin/views/argument_default/Session.php, line 130

Class

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

Namespace

Drupal\views_extras\Plugin\views\argument_default

Code

public function getArgument() {
  if (!empty($key = $this->options['session_key'])) {
    $keys = explode('::', $key);
    if ($value = $this
      ->findArrayValue($_SESSION, $keys)) {
      return $value;
    }
  }
  if (!empty($value = $this->options['fallback_value'])) {
    return $this->token
      ->replace($value, [
      'user' => $this->current_user,
    ]);
  }
  return $value;
}