This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/core/modules/views/views.post_update.php

37 lines
782 B
PHP
Raw Normal View History

<?php
/**
* @file
* Post update functions for Views.
*/
/**
* @addtogroup updates-8.0.0-beta
* @{
*/
/**
* Update the cacheability metadata for all views.
*/
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();
}
}
/**
* @} End of "addtogroup updates-8.0.0-beta".
*/