class StatisticsLastCommentName in Drupal 10
Same name and namespace in other branches
- 8 core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\sort\StatisticsLastCommentName
- 9 core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\sort\StatisticsLastCommentName
Sort handler to sort by last comment name which might be in 2 different fields.
Plugin annotation
@ViewsSort("comment_ces_last_comment_name");
Hierarchy
- class \Drupal\views\Plugin\views\sort\SortPluginBase extends \Drupal\views\Plugin\views\HandlerBase implements CacheableDependencyInterface
- class \Drupal\comment\Plugin\views\sort\StatisticsLastCommentName
Expanded class hierarchy of StatisticsLastCommentName
Related topics
File
- core/
modules/ comment/ src/ Plugin/ views/ sort/ StatisticsLastCommentName.php, line 15
Namespace
Drupal\comment\Plugin\views\sortView source
class StatisticsLastCommentName extends SortPluginBase {
public function query() {
$this
->ensureMyTable();
$definition = [
'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);
// @todo this might be safer if we had an ensure_relationship rather than guessing
// the table alias. Though if we did that we'd be guessing the relationship name
// so that doesn't matter that much.
$this->user_table = $this->query
->ensureTable('ces_users', $this->relationship, $join);
$this->user_field = $this->query
->addField($this->user_table, 'name');
// Add the field.
$this->query
->addOrderBy(NULL, "LOWER(COALESCE({$this->user_table}.name, {$this->tableAlias}.{$this->field}))", $this->options['order'], $this->tableAlias . '_' . $this->field);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SortPluginBase:: |
public | function | Display whether or not the sort order is ascending or descending. | |
SortPluginBase:: |
public | function | ||
SortPluginBase:: |
public | function | Basic options for all sort criteria. | 2 |
SortPluginBase:: |
public | function | Determine if a sort can be exposed. | |
SortPluginBase:: |
public | function | Provide default options for exposed sorts. | |
SortPluginBase:: |
protected | function | 1 | |
SortPluginBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyInterface:: |
|
SortPluginBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyInterface:: |
|
SortPluginBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyInterface:: |
|
SortPluginBase:: |
public | function | Shortcut to display the expose/hide button. | |
SortPluginBase:: |
protected | function | Shortcut to display the value form. | |
SortPluginBase:: |
protected | function | Provide a list of options for the default sort form. | |
SortPluginBase:: |
public | function | ||
SortPluginBase:: |
protected | function | ||
SortPluginBase:: |
public | function | Simple submit handler. | |
SortPluginBase:: |
public static | function | ||
SortPluginBase:: |
public | function | Validate the options form. | |
SortPluginBase:: |
public | function | Simple validate handler. | |
StatisticsLastCommentName:: |
public | function |
Called to add the sort to a query. Overrides SortPluginBase:: |