function View::generateDisplayId

Same name in other branches
  1. 9 core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::generateDisplayId()
  2. 10 core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::generateDisplayId()
  3. 11.x core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::generateDisplayId()

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

1 call to View::generateDisplayId()
View::addDisplay in core/modules/views/src/Entity/View.php
Adds a new display handler to the view, automatically creating an ID.

File

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

Class

View
Defines a View configuration entity class.

Namespace

Drupal\views\Entity

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.