function LayoutPluginManager::getSortedDefinitions

Same name in other branches
  1. 9 core/lib/Drupal/Core/Layout/LayoutPluginManager.php \Drupal\Core\Layout\LayoutPluginManager::getSortedDefinitions()
  2. 8.9.x core/lib/Drupal/Core/Layout/LayoutPluginManager.php \Drupal\Core\Layout\LayoutPluginManager::getSortedDefinitions()
  3. 11.x core/lib/Drupal/Core/Layout/LayoutPluginManager.php \Drupal\Core\Layout\LayoutPluginManager::getSortedDefinitions()

Return value

\Drupal\Core\Layout\LayoutDefinition[]

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 = $definitions ?? $this->getDefinitions();
    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;
}

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