You are here

protected function SectionStorageManager::findDefinitions in Drupal 8

Same name and namespace in other branches
  1. 9 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 61

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