function Date::opSimple

Same name in this branch
  1. 11.x core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date::opSimple()
Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::opSimple()
  2. 9 core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date::opSimple()
  3. 8.9.x core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::opSimple()
  4. 8.9.x core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date::opSimple()
  5. 10 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::opSimple()
  6. 10 core/modules/datetime/src/Plugin/views/filter/Date.php \Drupal\datetime\Plugin\views\filter\Date::opSimple()

Filters by a simple operator.

Overrides NumericFilter::opSimple

1 method overrides Date::opSimple()
Date::opSimple in core/modules/datetime/src/Plugin/views/filter/Date.php
Override parent method, which deals with dates as integers.

File

core/modules/views/src/Plugin/views/filter/Date.php, line 203

Class

Date
Filter to handle dates stored as a timestamp.

Namespace

Drupal\views\Plugin\views\filter

Code

protected function opSimple($field) {
  $value = intval(strtotime($this->value['value'], 0));
  if (!empty($this->value['type']) && $this->value['type'] == 'offset') {
    // Keep sign.
    $value = '***CURRENT_TIME***' . sprintf('%+d', $value);
  }
  // This is safe because we are manually scrubbing the value. It is necessary
  // to do it this way because $value is a formula when using an offset.
  $this->query
    ->addWhereExpression($this->options['group'], "{$field} {$this->operator} {$value}");
}

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