You are here

public function ViewUI::getDisplayEditPage in Views (for Drupal 7) 8.3

Helper function to return the used display_id for the edit page

This function handles access to the display.

File

views_ui/lib/Drupal/views_ui/ViewUI.php, line 124
Definition of Drupal\views_ui\ViewUI.

Class

ViewUI
Stores UI related temporary settings.

Namespace

Drupal\views_ui

Code

public function getDisplayEditPage($display_id) {

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

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

    // If a display is specified, but we don't have access to it, return
    // an access denied page.
    if ($display_id && (!isset($tabs[$display_id]) || isset($tabs[$display_id]['#access']) && !$tabs[$display_id]['#access'])) {
      return MENU_ACCESS_DENIED;
    }
    return $display_id;
  }
  elseif ($display_id) {
    return MENU_ACCESS_DENIED;
  }
  else {
    $display_id = NULL;
  }
  return $display_id;
}