View::generateDisplayId

protected View::generateDisplayId($plugin_id)

Generates a display ID of a certain plugin type.

Parameters

string $plugin_id: Which plugin should be used for the new display ID.

Return value

string

File

core/modules/views/src/Entity/View.php, line 208

Class

View
Defines a View configuration entity class.

Namespace

Drupal\views\Entity

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
protected function generateDisplayId($plugin_id) {
  // 'default' is singular and is unique, so just go with 'default'
  // for it. For all others, start counting.
  if ($plugin_id == 'default') {
    return 'default';
  }
  // Initial ID.
  $id = $plugin_id . '_1';
  $count = 1;
 
  // Loop through IDs based upon our style plugin name until
  // we find one that is unused.
  while (!empty($this->display[$id])) {
    $id = $plugin_id . '_' . ++$count;
  }
 
  return $id;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.