function NumericArgument::query

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

Overrides ArgumentPluginBase::query

File

core/modules/views/src/Plugin/views/argument/NumericArgument.php, line 92

Class

NumericArgument
Basic argument handler for arguments that are numeric.

Namespace

Drupal\views\Plugin\views\argument

Code

public function query($group_by = FALSE) {
    $this->ensureMyTable();
    if (!empty($this->options['break_phrase'])) {
        $break = static::breakString($this->argument, FALSE);
        $this->value = $break->value;
        $this->operator = $break->operator;
    }
    else {
        $this->value = [
            $this->argument,
        ];
    }
    $placeholder = $this->placeholder();
    $null_check = empty($this->options['not']) ? '' : " OR {$this->tableAlias}.{$this->realField} IS NULL";
    if (count($this->value) > 1) {
        $operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
        $placeholder .= '[]';
        $this->query
            ->addWhereExpression(0, "{$this->tableAlias}.{$this->realField} {$operator}({$placeholder})" . $null_check, [
            $placeholder => $this->value,
        ]);
    }
    else {
        $operator = empty($this->options['not']) ? '=' : '!=';
        $this->query
            ->addWhereExpression(0, "{$this->tableAlias}.{$this->realField} {$operator} {$placeholder}" . $null_check, [
            $placeholder => $this->argument,
        ]);
    }
}

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