function SectionStorageManager::findDefinitions

Same name in other branches
  1. 9 core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php \Drupal\layout_builder\SectionStorage\SectionStorageManager::findDefinitions()
  2. 8.9.x core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php \Drupal\layout_builder\SectionStorage\SectionStorageManager::findDefinitions()
  3. 11.x core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php \Drupal\layout_builder\SectionStorage\SectionStorageManager::findDefinitions()

Overrides DefaultPluginManager::findDefinitions

File

core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php, line 57

Class

SectionStorageManager
Provides the Section Storage type plugin manager.

Namespace

Drupal\layout_builder\SectionStorage

Code

protected function findDefinitions() {
    $definitions = parent::findDefinitions();
    // Sort the definitions by their weight while preserving the original order
    // for those with matching weights.
    $weights = array_map(function (SectionStorageDefinition $definition) {
        return $definition->getWeight();
    }, $definitions);
    $ids = array_keys($definitions);
    array_multisort($weights, $ids, $definitions);
    return $definitions;
}

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