function views_post_update_update_cacheability_metadata in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/views/views.post_update.php \views_post_update_update_cacheability_metadata()
Update the cacheability metadata for all views.
1 string reference to 'views_post_update_update_cacheability_metadata'
- UpdatePathRC1TestBaseTest::testDatabaseLoaded in core/
modules/ system/ src/ Tests/ Update/ UpdatePathRC1TestBaseTest.php - Tests that the database was properly loaded.
File
- core/
modules/ views/ views.post_update.php, line 19 - Post update functions for Views.
Code
function views_post_update_update_cacheability_metadata() {
// Load all views.
$views = \Drupal::entityManager()
->getStorage('view')
->loadMultiple();
/* @var \Drupal\views\Entity\View[] $views */
foreach ($views as $view) {
$displays = $view
->get('display');
foreach (array_keys($displays) as $display_id) {
$display =& $view
->getDisplay($display_id);
// Unset the cache_metadata key, so all cacheability metadata for the
// display is recalculated.
unset($display['cache_metadata']);
}
$view
->save();
}
}