function ViewEditForm::getDisplayTab

Same name in other branches
  1. 8.9.x core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::getDisplayTab()
  2. 10 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::getDisplayTab()
  3. 11.x core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::getDisplayTab()

Returns a renderable array representing the edit page for one display.

2 calls to ViewEditForm::getDisplayTab()
ViewEditForm::form in core/modules/views_ui/src/ViewEditForm.php
Gets the actual form array to be built.
ViewEditForm::rebuildCurrentTab in core/modules/views_ui/src/ViewEditForm.php
Regenerate the current tab for AJAX updates.

File

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

Class

ViewEditForm
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function getDisplayTab($view) {
    $build = [];
    $display_id = $this->displayID;
    $display = $view->getExecutable()->displayHandlers
        ->get($display_id);
    // If the plugin doesn't exist, display an error message instead of an edit
    // page.
    if (empty($display)) {
        // @TODO: Improved UX for the case where a plugin is missing.
        $build['#markup'] = $this->t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", [
            '@display' => $display->display['id'],
            '@plugin' => $display->display['display_plugin'],
        ]);
    }
    else {
        $build['details'] = $this->getDisplayDetails($view, $display->display);
    }
    // In AJAX context, ViewUI::rebuildCurrentTab() returns this outside of form
    // context, so hook_form_view_edit_form_alter() is insufficient.
    // @todo remove this after
    //   https://www.drupal.org/project/drupal/issues/3087455 has been resolved.
    \Drupal::moduleHandler()->alter('views_ui_display_tab', $build, $view, $display_id);
    // Because themes can implement hook_form_FORM_ID_alter() and because this
    // is a workaround for hook_form_view_edit_form_alter() being insufficient,
    // also invoke this on themes.
    // @todo remove this after
    //   https://www.drupal.org/project/drupal/issues/3087455 has been resolved.
    $this->themeManager
        ->alter('views_ui_display_tab', $build, $view, $display_id);
    return $build;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.