function views_update_8101 in Drupal 8
Set default values for enabled/expanded flag on page displays.
File
- core/
modules/ views/ views.install, line 357 - Contains install and update functions for Views.
Code
function views_update_8101() {
$config_factory = \Drupal::configFactory();
foreach ($config_factory
->listAll('views.view.') as $view_config_name) {
$view = $config_factory
->getEditable($view_config_name);
$save = FALSE;
foreach ($view
->get('display') as $display_id => $display) {
if ($display['display_plugin'] == 'page') {
$display['display_options']['menu']['enabled'] = TRUE;
$display['display_options']['menu']['expanded'] = FALSE;
$view
->set("display.{$display_id}", $display);
$save = TRUE;
}
}
if ($save) {
$view
->save();
}
}
}