function LayoutPluginManager::getSortedDefinitions

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Layout/LayoutPluginManager.php \Drupal\Core\Layout\LayoutPluginManager::getSortedDefinitions()
  2. 10 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[]

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

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