1 views.install views_update_1009()

Enable Ajax History for all Views using AJAX.

Related topics

File

core/modules/views/views.install, line 219
Contains install and update functions for Views.

Code

function views_update_1009() {
  $views = config_get_names_with_prefix('views.view');
  $views_ajax_history = module_exists('views_ajax_history');
  foreach ($views as $view_name) {
    $config = config($view_name);
    $use_ajax_default = $config->get('display.default.display_options.use_ajax');
    $displays = $config->get('display');
    foreach ($displays as $display_name => $display_config) {
      if (isset($display_config['display_options']['use_ajax']) && $display_config['display_options']['use_ajax'] == FALSE) {
        continue;
      }
      if ($use_ajax_default || !empty($display_config['display_options']['use_ajax'])) {
        // Set the value based on whether views_ajax_history module was enabled.
        $config->set('display.' . $display_name . '.display_options.enable_ajax_history', $views_ajax_history);
        $config->set('display.' . $display_name . '.display_options.exclude_ajax_args', '');
      }
    }

    $config->save();
  }

  // Remove the entry for the views_ajax_history module in the system table.
  // This will "disable" the module if present. No other configuration was
  // present for this module.
  db_query("DELETE FROM {system} WHERE name = 'views_ajax_history' AND type = 'module'");
}