function views_update_8101

Set default values for enabled/expanded flag on page displays.

File

core/modules/views/views.install, line 357

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

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