You are here

public function ViewUI::submitDisplayDuplicate in Views (for Drupal 7) 8.3

Submit handler to duplicate a display for a view.

File

views_ui/lib/Drupal/views_ui/ViewUI.php, line 787
Definition of Drupal\views_ui\ViewUI.

Class

ViewUI
Stores UI related temporary settings.

Namespace

Drupal\views_ui

Code

public function submitDisplayDuplicate($form, &$form_state) {
  $display_id = $form_state['display_id'];

  // Create the new display.
  $display = $this->storage->display[$display_id];
  $new_display_id = $this->storage
    ->addDisplay($display['display_plugin']);
  $this->storage->display[$new_display_id] = $display;
  $this->storage->display[$new_display_id]['id'] = $new_display_id;

  // By setting the current display the changed marker will appear on the new
  // display.
  $this->current_display = $new_display_id;
  views_ui_cache_set($this);

  // Redirect to the new display's edit page.
  $form_state['redirect'] = 'admin/structure/views/view/' . $this->storage->name . '/edit/' . $new_display_id;
}