public function ViewExecutable::access

Determine if the given user has access to the view. Note that this sets the display handler if it hasn't been.

File

drupal/core/modules/views/lib/Drupal/views/ViewExecutable.php, line 1545
Definition of Drupal\views\ViewExecutable.

Class

ViewExecutable
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Namespace

Drupal\views

Code

public function access($displays = NULL, $account = NULL) {

  // Noone should have access to disabled views.
  if (!$this->storage
    ->isEnabled()) {
    return FALSE;
  }
  if (!isset($this->current_display)) {
    $this
      ->initDisplay();
  }
  if (!$account) {
    $account = $GLOBALS['user'];
  }

  // We can't use choose_display() here because that function
  // calls this one.
  $displays = (array) $displays;
  foreach ($displays as $display_id) {
    if (!empty($this->displayHandlers[$display_id])) {
      if ($this->displayHandlers[$display_id]
        ->access($account)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}