You are here

function views_invalidate_cache in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/views.module \views_invalidate_cache()

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

3 calls to views_invalidate_cache()
AdvancedSettingsForm::cacheSubmit in core/modules/views_ui/src/Form/AdvancedSettingsForm.php
Submission handler to clear the Views cache.
DisplayTest::testInvalidDisplayPlugins in core/modules/views/tests/src/Functional/Plugin/DisplayTest.php
Tests invalid display plugins.
View::postSave in core/modules/views/src/Entity/View.php
Acts on a saved entity before the insert or update hook is invoked.
1 string reference to 'views_invalidate_cache'
views_hook_info in core/modules/views/views.module
Implements hook_hook_info().

File

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

Code

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');
}