StatisticsLastCommentName.php in Zircon Profile 8
File
core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php
View source
<?php
namespace Drupal\comment\Plugin\views\sort;
use Drupal\views\Plugin\views\sort\SortPluginBase;
class StatisticsLastCommentName extends SortPluginBase {
public function query() {
$this
->ensureMyTable();
$definition = array(
'table' => 'users_field_data',
'field' => 'uid',
'left_table' => 'comment_entity_statistics',
'left_field' => 'last_comment_uid',
);
$join = \Drupal::service('plugin.manager.views.join')
->createInstance('standard', $definition);
$this->user_table = $this->query
->ensureTable('ces_users', $this->relationship, $join);
$this->user_field = $this->query
->addField($this->user_table, 'name');
$this->query
->addOrderBy(NULL, "LOWER(COALESCE({$this->user_table}.name, {$this->tableAlias}.{$this->field}))", $this->options['order'], $this->tableAlias . '_' . $this->field);
}
}