You are here

content_moderation_test_views.module in Drupal 10

Module file for the content moderation test views module.

File

core/modules/content_moderation/tests/modules/content_moderation_test_views/content_moderation_test_views.module
View source
<?php

/**
 * @file
 * Module file for the content moderation test views module.
 */
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ViewExecutable;

/**
 * Implements hook_views_query_alter().
 *
 * @see \Drupal\Tests\content_moderation\Kernel\ViewsModerationStateSortTest::testSortRevisionBaseTable()
 */
function content_moderation_test_views_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {

  // Add a secondary sort order to ensure consistent builds when testing click
  // and table sorting.
  if ($view
    ->id() === 'test_content_moderation_state_sort_revision_table') {
    $query
      ->addOrderBy('node_field_revision', 'vid', 'ASC');
  }
}