You are here

public function ModerationStateField::clickSort in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php \Drupal\content_moderation\Plugin\views\field\ModerationStateField::clickSort()
  2. 10 core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php \Drupal\content_moderation\Plugin\views\field\ModerationStateField::clickSort()

Called to determine what to tell the clicksorter.

Overrides EntityField::clickSort

File

core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php, line 22

Class

ModerationStateField
A field handler for the computed moderation_state field.

Namespace

Drupal\content_moderation\Plugin\views\field

Code

public function clickSort($order) {
  $this
    ->ensureMyTable();

  // This could be derived from the content_moderation_state entity table
  // mapping, however this is an internal entity type whose storage should
  // remain constant.
  $storage = $this->entityTypeManager
    ->getStorage('content_moderation_state');
  $storage_definition = $this->entityFieldManager
    ->getActiveFieldStorageDefinitions('content_moderation_state')['moderation_state'];
  $column_name = $storage
    ->getTableMapping()
    ->getFieldColumnName($storage_definition, 'value');
  $this->aliases[$column_name] = $this->tableAlias . '.' . $column_name;
  $this->query
    ->addOrderBy(NULL, NULL, $order, $this->aliases[$column_name]);
}