LogStandardSort.php in Log entity 2.x
File
src/Plugin/views/sort/LogStandardSort.php
View source
<?php
namespace Drupal\log\Plugin\views\sort;
use Drupal\views\Plugin\views\sort\Date;
class LogStandardSort extends Date {
public function query() {
$this
->ensureMyTable();
switch ($this->options['granularity']) {
case 'second':
default:
$this->query
->addOrderBy($this->tableAlias, $this->realField, $this->options['order']);
$this->query
->addOrderBy($this->tableAlias, 'id', $this->options['order']);
return;
case 'minute':
$formula = $this
->getDateFormat('YmdHi');
break;
case 'hour':
$formula = $this
->getDateFormat('YmdH');
break;
case 'day':
$formula = $this
->getDateFormat('Ymd');
break;
case 'month':
$formula = $this
->getDateFormat('Ym');
break;
case 'year':
$formula = $this
->getDateFormat('Y');
break;
}
$this->query
->addOrderBy(NULL, $formula, $this->options['order'], $this->tableAlias . '_' . $this->field . '_' . $this->options['granularity']);
$this->query
->addOrderBy($this->tableAlias, 'id', $this->options['order']);
}
public function getDateField() {
return $this->query
->getDateField("{$this->tableAlias}.timestamp");
}
}