You are here

public function LayoutPluginManager::getSortedDefinitions in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Layout/LayoutPluginManager.php \Drupal\Core\Layout\LayoutPluginManager::getSortedDefinitions()

Return value

\Drupal\Core\Layout\LayoutDefinition[]

Overrides LayoutPluginManagerInterface::getSortedDefinitions

1 call to LayoutPluginManager::getSortedDefinitions()
LayoutPluginManager::getGroupedDefinitions in core/lib/Drupal/Core/Layout/LayoutPluginManager.php

File

core/lib/Drupal/Core/Layout/LayoutPluginManager.php, line 199

Class

LayoutPluginManager
Provides a plugin manager for layouts.

Namespace

Drupal\Core\Layout

Code

public function getSortedDefinitions(array $definitions = NULL, $label_key = 'label') {

  // Sort the plugins first by category, then by label.
  $definitions = isset($definitions) ? $definitions : $this
    ->getDefinitions();

  // Suppress errors because PHPUnit will indirectly modify the contents,
  // triggering https://bugs.php.net/bug.php?id=50688.
  @uasort($definitions, function (LayoutDefinition $a, LayoutDefinition $b) {
    if ($a
      ->getCategory() != $b
      ->getCategory()) {
      return strnatcasecmp($a
        ->getCategory(), $b
        ->getCategory());
    }
    return strnatcasecmp($a
      ->getLabel(), $b
      ->getLabel());
  });
  return $definitions;
}