public function Date::acceptExposedInput in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::acceptExposedInput()
Do some minor translation of the exposed input.
Overrides NumericFilter::acceptExposedInput
File
- core/
modules/ views/ src/ Plugin/ views/ filter/ Date.php, line 119
Class
- Date
- Filter to handle dates stored as a timestamp.
Namespace
Drupal\views\Plugin\views\filterCode
public function acceptExposedInput($input) {
if (empty($this->options['exposed'])) {
return TRUE;
}
// Store this because it will get overwritten.
$type = NULL;
if ($this
->isAGroup()) {
if (is_array($this->group_info)) {
$type = $this->group_info['type'];
}
}
else {
$type = $this->value['type'];
}
$rc = parent::acceptExposedInput($input);
// Restore what got overwritten by the parent.
if (!is_null($type)) {
$this->value['type'] = $type;
}
// Don't filter if value(s) are empty.
$operators = $this
->operators();
if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) {
$operator = $input[$this->options['expose']['operator_id']];
}
else {
$operator = $this->operator;
}
if ($operators[$operator]['values'] == 1) {
// When the operator is either <, <=, =, !=, >=, > or regular_expression
// the input contains only one value.
if ($this->value['value'] == '') {
return FALSE;
}
}
elseif ($operators[$operator]['values'] == 2) {
// When the operator is either between or not between the input contains
// two values.
if ($this->value['min'] == '' || $this->value['max'] == '') {
return FALSE;
}
}
return $rc;
}