protected function ViewFormControllerBase::prepareEntity

Overrides Drupal\Core\Entity\EntityFormController::prepareForm().

Overrides EntityFormController::prepareEntity

2 methods override ViewFormControllerBase::prepareEntity()
ViewAddFormController::prepareEntity in drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewAddFormController.php
Overrides Drupal\Core\Entity\EntityFormController::prepareForm().
ViewCloneFormController::prepareEntity in drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php
Overrides \Drupal\Core\Entity\EntityFormController::prepareForm().

File

drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewFormControllerBase.php, line 23
Contains Drupal\views_ui\ViewFormControllerBase.

Class

ViewFormControllerBase
Base form controller for Views forms.

Namespace

Drupal\views_ui

Code

protected function prepareEntity(EntityInterface $view) {

  // Determine the displays available for editing.
  if ($tabs = $this
    ->getDisplayTabs($view)) {

    // If a display isn't specified, use the first one.
    if (empty($view->displayID)) {
      foreach ($tabs as $id => $tab) {
        if (!isset($tab['#access']) || $tab['#access']) {
          $view->displayID = $id;
          break;
        }
      }
    }

    // If a display is specified, but we don't have access to it, return
    // an access denied page.
    if ($view->displayID && !isset($tabs[$view->displayID])) {
      throw new NotFoundHttpException();
    }
    elseif ($view->displayID && (isset($tabs[$view->displayID]['#access']) && !$tabs[$view->displayID]['#access'])) {
      throw new AccessDeniedHttpException();
    }
  }
  elseif ($view->displayID) {
    throw new NotFoundHttpException();
  }
}