Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. QueryParameter.php

function QueryParameter::getArgument

Overrides ArgumentDefaultPluginBase::getArgument

File

core/modules/views/src/Plugin/views/argument_default/QueryParameter.php, line 67

Class

QueryParameter
A query parameter argument default handler.

Namespace

Drupal\views\Plugin\views\argument_default

Code

public function getArgument() {
    $current_request = $this->view
        ->getRequest();
    // Convert a[b][c][d] into ['a', 'b', 'c', 'd'].
    $path = array_filter(preg_split('#(\\[|\\]\\[|\\])#', $this->options['query_param']));
    if ($current_request->query
        ->has($path[0])) {
        $query = $current_request->query
            ->all();
        $param = NestedArray::getValue($query, $path);
        if (is_array($param)) {
            $conjunction = $this->options['multiple'] == 'and' ? ',' : '+';
            $param = implode($conjunction, $param);
        }
        return $param;
    }
    else {
        // Otherwise, use the fixed fallback value.
        return $this->options['fallback'];
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal