public function DateRange::getDateField in Views Contextual Range Filter 8
Overrides Drupal\views\Plugin\views\HandlerBase\getDateField().
Overrides HandlerBase::getDateField
File
- src/
Plugin/ views/ argument/ DateRange.php, line 155
Class
- DateRange
- Argument handler to accept a date range.
Namespace
Drupal\contextual_range_filter\Plugin\views\argumentCode
public function getDateField() {
// This is a littly iffy... Basically we assume that, unless the field is
// a known timestamp by the name of 'changed*' or 'created*' or 'login' or
// or 'access', the field is a Drupal DateTime, which presents itself to
// MySQL as a string of the format '2020-12-31T23:59:59'.
// Perhaps a better approach is to have a checkbox on the Contextual Filter
// form for the user to indicate whether the date is a timestamp or a
// DateTime (i.e. string).
$first7chars = substr($this->field, 0, 7);
$is_string_date = $first7chars != 'changed' && $first7chars != 'created' && $this->field != 'login' && $this->field != 'access';
return $this->query
->getDateField("{$this->tableAlias}.{$this->realField}", $is_string_date);
}