function ModerationStateField::clickSort

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. 8.9.x core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php \Drupal\content_moderation\Plugin\views\field\ModerationStateField::clickSort()
  3. 10 core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php \Drupal\content_moderation\Plugin\views\field\ModerationStateField::clickSort()

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]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.