ModerationStateSort.php

Same filename in other branches
  1. 9 core/modules/content_moderation/src/Plugin/views/sort/ModerationStateSort.php
  2. 8.9.x core/modules/content_moderation/src/Plugin/views/sort/ModerationStateSort.php
  3. 10 core/modules/content_moderation/src/Plugin/views/sort/ModerationStateSort.php

Namespace

Drupal\content_moderation\Plugin\views\sort

File

core/modules/content_moderation/src/Plugin/views/sort/ModerationStateSort.php

View source
<?php

namespace Drupal\content_moderation\Plugin\views\sort;

use Drupal\content_moderation\Plugin\views\ModerationStateJoinViewsHandlerTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\views\Attribute\ViewsSort;
use Drupal\views\Plugin\views\sort\SortPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Enables sorting for the computed moderation_state field.
 *
 * @ingroup views_sort_handlers
 */
class ModerationStateSort extends SortPluginBase {
    use ModerationStateJoinViewsHandlerTrait;
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * Creates an instance of ModerationStateFilter.
     *
     * @param array $configuration
     *   A configuration array containing information about the plugin instance.
     * @param string $plugin_id
     *   The plugin ID for the plugin instance.
     * @param mixed $plugin_definition
     *   The plugin implementation definition.
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     */
    public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->entityTypeManager = $entity_type_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
        return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity_type.manager'));
    }

}

Classes

Title Deprecated Summary
ModerationStateSort Enables sorting for the computed moderation_state field.

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