public function String::query in Views (for Drupal 7) 8.3
Same name in this branch
- 8.3 lib/Drupal/views/Plugin/views/filter/String.php \Drupal\views\Plugin\views\filter\String::query()
- 8.3 lib/Drupal/views/Plugin/views/argument/String.php \Drupal\views\Plugin\views\argument\String::query()
Build the query based upon the formula
Overrides ArgumentPluginBase::query
File
- lib/
Drupal/ views/ Plugin/ views/ argument/ String.php, line 182 - Definition of Drupal\views\Plugin\views\argument\String.
Class
- String
- Basic argument handler to implement string arguments that may have length limits.
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
->breakPhraseString($argument, $this);
}
else {
$this->value = array(
$argument,
);
$this->operator = 'or';
}
if (!empty($this->definition['many to one'])) {
if (!empty($this->options['glossary'])) {
$this->helper->formula = TRUE;
}
$this->helper
->ensureMyTable();
$this->helper
->add_filter();
return;
}
$this
->ensureMyTable();
$formula = FALSE;
if (empty($this->options['glossary'])) {
$field = "{$this->tableAlias}.{$this->realField}";
}
else {
$formula = TRUE;
$field = $this
->get_formula();
}
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 = array(
$placeholder => $argument,
);
$this->query
->add_where_expression(0, $field, $placeholders);
}
else {
$this->query
->add_where(0, $field, $argument, $operator);
}
}