class StatisticsLastCommentName
Same name in this branch
- 9 core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\field\StatisticsLastCommentName
Same name and namespace in other branches
- 11.x core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\sort\StatisticsLastCommentName
- 11.x core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\field\StatisticsLastCommentName
- 10 core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\sort\StatisticsLastCommentName
- 10 core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\field\StatisticsLastCommentName
- 8.9.x core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\sort\StatisticsLastCommentName
- 8.9.x core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php \Drupal\comment\Plugin\views\field\StatisticsLastCommentName
Sort handler, sorts by last comment name which can be in 2 different fields.
Plugin annotation
@ViewsSort("comment_ces_last_comment_name");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\HandlerBase implements \Drupal\views\Plugin\views\ViewsHandlerInterface extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\sort\SortPluginBase implements \Drupal\Core\Cache\CacheableDependencyInterface extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\comment\Plugin\views\sort\StatisticsLastCommentName extends \Drupal\views\Plugin\views\sort\SortPluginBase
- class \Drupal\views\Plugin\views\sort\SortPluginBase implements \Drupal\Core\Cache\CacheableDependencyInterface extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\views\Plugin\views\HandlerBase implements \Drupal\views\Plugin\views\ViewsHandlerInterface extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of StatisticsLastCommentName
Related topics
File
-
core/
modules/ comment/ src/ Plugin/ views/ sort/ StatisticsLastCommentName.php, line 14
Namespace
Drupal\comment\Plugin\views\sortView source
class StatisticsLastCommentName extends SortPluginBase {
/**
* The users table.
*/
protected $user_table;
/**
* The user name field.
*/
protected $user_field;
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.