37 lines
782 B
PHP
37 lines
782 B
PHP
|
<?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".
|
||
|
*/
|