ModerationStateField.php

Same filename in other branches
  1. 9 core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php
  2. 10 core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php
  3. 11.x core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php

Namespace

Drupal\content_moderation\Plugin\views\field

File

core/modules/content_moderation/src/Plugin/views/field/ModerationStateField.php

View source
<?php

namespace Drupal\content_moderation\Plugin\views\field;

use Drupal\content_moderation\Plugin\views\ModerationStateJoinViewsHandlerTrait;
use Drupal\views\Plugin\views\field\EntityField;

/**
 * A field handler for the computed moderation_state field.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("moderation_state_field")
 */
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]);
    }

}

Classes

Title Deprecated Summary
ModerationStateField A field handler for the computed moderation_state field.

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