function StringArgument::query
Same name in other branches
- 9 core/modules/views/src/Plugin/views/argument/StringArgument.php \Drupal\views\Plugin\views\argument\StringArgument::query()
- 8.9.x core/modules/views/src/Plugin/views/argument/StringArgument.php \Drupal\views\Plugin\views\argument\StringArgument::query()
- 10 core/modules/views/src/Plugin/views/argument/StringArgument.php \Drupal\views\Plugin\views\argument\StringArgument::query()
Build the query based upon the formula.
Overrides ArgumentPluginBase::query
File
-
core/
modules/ views/ src/ Plugin/ views/ argument/ StringArgument.php, line 207
Class
- StringArgument
- Argument handler for string.
Namespace
Drupal\views\Plugin\views\argumentCode
public function query($group_by = FALSE) {
$argument = $this->argument;
if (!empty($this->options['transform_dash'])) {
$argument = strtr($argument, '-', ' ');
}
if (!empty($this->options['break_phrase'])) {
$this->unpackArgumentValue();
}
else {
$this->value = [
$argument,
];
$this->operator = 'or';
}
// Support case-insensitive substring comparisons for PostgreSQL by
// converting the arguments to lowercase.
if ($this->options['case'] != 'none' && Database::getConnection()->databaseType() == 'pgsql') {
foreach ($this->value as $key => $value) {
$this->value[$key] = mb_strtolower($value);
}
}
if (!empty($this->definition['many to one'])) {
if (!empty($this->options['glossary'])) {
$this->helper->formula = TRUE;
}
$this->helper
->ensureMyTable();
$this->helper
->addFilter();
return;
}
$this->ensureMyTable();
$formula = FALSE;
if (empty($this->options['glossary'])) {
$field = "{$this->tableAlias}.{$this->realField}";
}
else {
$formula = TRUE;
$field = $this->getFormula();
}
if (count($this->value) > 1) {
$operator = 'IN';
$argument = $this->value;
}
else {
$operator = '=';
}
if ($formula) {
$placeholder = $this->placeholder();
if ($operator == 'IN') {
$field .= " IN({$placeholder})";
}
else {
$field .= ' = ' . $placeholder;
}
$placeholders = [
$placeholder => $argument,
];
$this->query
->addWhereExpression(0, $field, $placeholders);
}
else {
$this->query
->addWhere(0, $field, $argument, $operator);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.