You are here

public function ViewsUIController::edit in Drupal 10

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

Returns the form to edit a view.

Parameters

\Drupal\views_ui\ViewUI $view: The view to be edited.

string|null $display_id: (optional) The display ID being edited. Defaults to NULL, which will load the first available display.

Return value

array An array containing the Views edit and preview forms.

1 string reference to 'ViewsUIController::edit'
views_ui.routing.yml in core/modules/views_ui/views_ui.routing.yml
core/modules/views_ui/views_ui.routing.yml

File

core/modules/views_ui/src/Controller/ViewsUIController.php, line 221

Class

ViewsUIController
Returns responses for Views UI routes.

Namespace

Drupal\views_ui\Controller

Code

public function edit(ViewUI $view, $display_id = NULL) {
  $name = $view
    ->label();
  $data = $this->viewsData
    ->get($view
    ->get('base_table'));
  if (isset($data['table']['base']['title'])) {
    $name .= ' (' . $data['table']['base']['title'] . ')';
  }
  $build['#title'] = $name;
  $build['edit'] = $this
    ->entityFormBuilder()
    ->getForm($view, 'edit', [
    'display_id' => $display_id,
  ]);
  $build['preview'] = $this
    ->entityFormBuilder()
    ->getForm($view, 'preview', [
    'display_id' => $display_id,
  ]);
  return $build;
}