function views_ui_ajax_callback

Page callback: Calls a method on a view and reloads the listing page.

Parameters

Drupal\views\ViewExectuable $view: The config entity being acted upon.

string $op: The operation to perform, e.g., 'enable' or 'disable'.

Return value

mixed Either returns the listing page as JSON, or calls drupal_goto() to redirect back to the listing page.

1 string reference to 'views_ui_ajax_callback'
views_ui_menu in drupal/core/modules/views/views_ui/views_ui.module
Implements hook_menu().

File

drupal/core/modules/views/views_ui/views_ui.module, line 702
Provide structure for the administrative interface to Views.

Code

function views_ui_ajax_callback(ViewExecutable $view, $op) {

  // Perform the operation.
  $view->storage
    ->{$op}();

  // If the request is via AJAX, return the rendered list as JSON.
  if (drupal_container()
    ->get('request')->request
    ->get('js')) {
    $list = entity_list_controller('view')
      ->render();
    $commands = array(
      ajax_command_replace('#views-entity-list', drupal_render($list)),
    );
    return new JsonResponse(ajax_render($commands));
  }
  else {
    $entity_info = entity_get_info('view');
    drupal_goto('admin/structure/views');
  }
}