You are here

function views_ajax_history_update_8001 in Views AJAX History 8

Enable the ajax_history views display extender.

File

./views_ajax_history.install, line 13

Code

function views_ajax_history_update_8001() {
  views_ajax_history_update_views_settings_handler();

  // Keep the previous behavior of the module by enabling the new 'ajax_history'
  // display extender on every view that uses AJAX.
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory
    ->listAll('views.view.') as $view_config_name) {
    $config = $config_factory
      ->getEditable($view_config_name);
    if (!$config
      ->get('display')['default']['display_options']['use_ajax'] == TRUE) {
      continue;
    }
    $save = FALSE;
    foreach ($config
      ->get('display') as $display_id => $display) {
      if (!isset($display['display_options']['display_extenders']['ajax_history'])) {
        $display['display_options']['display_extenders']['ajax_history']['enable_history'] = TRUE;
        $config
          ->set("display.{$display_id}", $display);
        $save = TRUE;
      }
    }
    if ($save) {
      $config
        ->save(TRUE);
    }
  }
}