duplicateDisplayAsType example


  public function submitDuplicateDisplayAsType($form, FormStateInterface $form_state) {
    /** @var \Drupal\views\ViewEntityInterface $view */
    $view = $this->entity;
    $display_id = $this->displayID;

    // Create the new display.     $parents = $form_state->getTriggeringElement()['#parents'];
    $display_type = array_pop($parents);

    $new_display_id = $view->duplicateDisplayAsType($display_id$display_type);

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

    // Redirect to the new display's edit page.     $form_state->setRedirect('entity.view.edit_display_form', [
      'view' => $view->id(),
      'display_id' => $new_display_id,
    ]);
  }
/** * {@inheritdoc} */
  public function getExecutable() {
    return $this->storage->getExecutable();
  }

  /** * {@inheritdoc} */
  public function duplicateDisplayAsType($old_display_id$new_display_type) {
    return $this->storage->duplicateDisplayAsType($old_display_id$new_display_type);
  }

  /** * {@inheritdoc} */
  public function mergeDefaultDisplaysOptions() {
    $this->storage->mergeDefaultDisplaysOptions();
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.