views_test_config.module
Same filename in other branches
Contains the "views_test_config" module main functionality.
File
-
core/
modules/ views/ tests/ modules/ views_test_config/ views_test_config.module
View source
<?php
/**
* @file
* Contains the "views_test_config" module main functionality.
*/
use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\ViewExecutable;
/**
* Implements hook_ENTITY_TYPE_load().
*/
function views_test_config_view_load(array $views) {
// Emulate a severely broken view: this kind of view configuration cannot be
// saved, it can likely be returned only by a corrupt active configuration.
$broken_view_id = \Drupal::state()->get('views_test_config.broken_view');
if (isset($views[$broken_view_id])) {
$display =& $views[$broken_view_id]->getDisplay('default');
$display['display_options']['fields']['id_broken'] = NULL;
}
}
/**
* Implements hook_views_post_render().
*/
function views_test_config_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
if (\Drupal::state()->get('views_test_config.views_post_render_cache_tag')) {
\Drupal::state()->set('views_test_config.views_post_render_called', TRUE);
// Set a cache key on output to ensure ViewsSelection::stripAdminAndAnchorTagsFromResults
// correctly handles elements that aren't result rows.
$output['#cache']['tags'][] = 'foo';
}
}
function _views_test_config_disable_broken_handler(array &$definitions, string $handler_type) : void {
if (in_array($handler_type, \Drupal::state()->get('views_test_config_disable_broken_handler', []))) {
unset($definitions['broken']);
}
}
function views_test_config_views_plugins_area_alter(array &$definitions) : void {
_views_test_config_disable_broken_handler($definitions, 'area');
}
function views_test_config_views_plugins_argument_alter(array &$definitions) : void {
_views_test_config_disable_broken_handler($definitions, 'argument');
}
function views_test_config_views_plugins_field_alter(array &$definitions) : void {
_views_test_config_disable_broken_handler($definitions, 'field');
}
function views_test_config_views_plugins_filter_alter(array &$definitions) : void {
_views_test_config_disable_broken_handler($definitions, 'filter');
}
function views_test_config_views_plugins_relationship_alter(array &$definitions) : void {
_views_test_config_disable_broken_handler($definitions, 'relationship');
}
function views_test_config_views_plugins_sort_alter(array &$definitions) : void {
_views_test_config_disable_broken_handler($definitions, 'sort');
}
Functions
Title | Deprecated | Summary |
---|---|---|
views_test_config_views_plugins_area_alter | ||
views_test_config_views_plugins_argument_alter | ||
views_test_config_views_plugins_field_alter | ||
views_test_config_views_plugins_filter_alter | ||
views_test_config_views_plugins_relationship_alter | ||
views_test_config_views_plugins_sort_alter | ||
views_test_config_views_post_render | Implements hook_views_post_render(). | |
views_test_config_view_load | Implements hook_ENTITY_TYPE_load(). | |
_views_test_config_disable_broken_handler |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.