You are here

protected function SectionStorageManager::findDefinitions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php \Drupal\layout_builder\SectionStorage\SectionStorageManager::findDefinitions()

Finds plugin definitions.

Return value

array List of definitions to store in cache.

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