function views_invalidate_cache

Same name in other branches
  1. 9 core/modules/views/views.module \views_invalidate_cache()
  2. 8.9.x core/modules/views/views.module \views_invalidate_cache()
  3. 11.x core/modules/views/views.module \views_invalidate_cache()

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

4 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::postDelete in core/modules/views/src/Entity/View.php
Acts on deleted entities before the delete hook is invoked.
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 488

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.