views_invalidate_cache

views_invalidate_cache()

Invalidate the views cache, forcing a rebuild on the next grab of table data.

File

core/modules/views/views.module, line 461
Primarily Drupal hooks and global API functions to manipulate views.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function views_invalidate_cache() {
  // Set the menu as needed to be rebuilt.
  \Drupal::service('router.builder')->setRebuildNeeded();
 
  $module_handler = \Drupal::moduleHandler();
 
  // Reset the RouteSubscriber from views.
  \Drupal::getContainer()->get('views.route_subscriber')->reset();
 
  // Invalidate the block cache to update views block derivatives.
  if ($module_handler->moduleExists('block')) {
    \Drupal::service('plugin.manager.block')->clearCachedDefinitions();
  }
 
  // Allow modules to respond to the Views cache being cleared.
  $module_handler->invokeAll('views_invalidate_cache');
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.