ViewExecutable::chooseDisplay

public ViewExecutable::chooseDisplay($displays)

Gets the first display that is accessible to the user.

Parameters

array|string $displays: Either a single display id or an array of display ids.

Return value

string The first accessible display id, at least default.

File

core/modules/views/src/ViewExecutable.php, line 735

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public function chooseDisplay($displays) {
  if (!is_array($displays)) {
    return $displays;
  }
 
  $this->initDisplay();
 
  foreach ($displays as $display_id) {
    if ($this->displayHandlers->get($display_id)->access($this->user)) {
      return $display_id;
    }
  }
 
  return 'default';
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.