You are here

class ModerationStateField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php \Drupal\content_moderation\Plugin\views\field\ModerationStateField
  2. 9 core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php \Drupal\content_moderation\Plugin\views\field\ModerationStateField

A field handler for the computed moderation_state field.

Plugin annotation

@ViewsField("moderation_state_field");

Hierarchy

Expanded class hierarchy of ModerationStateField

File

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

Namespace

Drupal\content_moderation\Plugin\views\field
View source
class ModerationStateField extends EntityField {
  use ModerationStateJoinViewsHandlerTrait;

  /**
   * {@inheritdoc}
   */
  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]);
  }

}

Members