You are here

public function ViewEditForm::submitDisplayUndoDelete in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDisplayUndoDelete()
  2. 9 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDisplayUndoDelete()

Submit handler to add a restore a removed display to a view.

File

core/modules/views_ui/src/ViewEditForm.php, line 613

Class

ViewEditForm
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function submitDisplayUndoDelete($form, FormStateInterface $form_state) {
  $view = $this->entity;

  // Create the new display
  $id = $form_state
    ->get('display_id');
  $displays = $view
    ->get('display');
  $displays[$id]['deleted'] = FALSE;
  $view
    ->set('display', $displays);

  // Store in cache
  $view
    ->cacheSet();

  // Redirect to the top-level edit page.
  $form_state
    ->setRedirect('entity.view.edit_display_form', [
    'view' => $view
      ->id(),
    'display_id' => $id,
  ]);
}