content_moderation_test_views.module
Same filename in other branches
- 9 core/modules/content_moderation/tests/modules/content_moderation_test_views/content_moderation_test_views.module
- 8.9.x core/modules/content_moderation/tests/modules/content_moderation_test_views/content_moderation_test_views.module
- 10 core/modules/content_moderation/tests/modules/content_moderation_test_views/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.
*/
declare (strict_types=1);
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');
}
}
/**
* Implements hook_views_data_alter().
*
* @see \Drupal\Tests\content_moderation\Kernel\ViewsModerationStateFilterTest
*/
function content_moderation_test_views_views_data_alter(array &$data) {
if (isset($data['users_field_data'])) {
$data['users_field_data']['uid_revision_test'] = [
'help' => t('Relate the content revision to the user who created it.'),
'real field' => 'uid',
'relationship' => [
'title' => t('Content revision authored'),
'help' => t('Relate the content revision to the user who created it. This relationship will create one record for each content revision item created by the user.'),
'id' => 'standard',
'base' => 'node_field_revision',
'base field' => 'uid',
'field' => 'uid',
'label' => t('node revisions'),
],
];
}
}
Functions
Title | Deprecated | Summary |
---|---|---|
content_moderation_test_views_views_data_alter | Implements hook_views_data_alter(). | |
content_moderation_test_views_views_query_alter | Implements hook_views_query_alter(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.