function CategorizingPluginManagerTrait::getSortedDefinitions
Same name in other branches
- 9 core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php \Drupal\Core\Plugin\CategorizingPluginManagerTrait::getSortedDefinitions()
- 8.9.x core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php \Drupal\Core\Plugin\CategorizingPluginManagerTrait::getSortedDefinitions()
- 11.x core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php \Drupal\Core\Plugin\CategorizingPluginManagerTrait::getSortedDefinitions()
2 calls to CategorizingPluginManagerTrait::getSortedDefinitions()
- BlockManager::getSortedDefinitions in core/
lib/ Drupal/ Core/ Block/ BlockManager.php - CategorizingPluginManagerTrait::getGroupedDefinitions in core/
lib/ Drupal/ Core/ Plugin/ CategorizingPluginManagerTrait.php
File
-
core/
lib/ Drupal/ Core/ Plugin/ CategorizingPluginManagerTrait.php, line 111
Class
- CategorizingPluginManagerTrait
- Provides a trait for the CategorizingPluginManagerInterface.
Namespace
Drupal\Core\PluginCode
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 ($a, $b) use ($label_key) {
if ((string) $a['category'] != (string) $b['category']) {
return strnatcasecmp($a['category'], $b['category']);
}
return strnatcasecmp($a[$label_key], $b[$label_key]);
});
return $definitions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.