You are here

public function CategorizingPluginManagerTrait::getGroupedDefinitions in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php \Drupal\Core\Plugin\CategorizingPluginManagerTrait::getGroupedDefinitions()
  2. 9 core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php \Drupal\Core\Plugin\CategorizingPluginManagerTrait::getGroupedDefinitions()

File

core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php, line 105

Class

CategorizingPluginManagerTrait
Provides a trait for the CategorizingPluginManagerInterface.

Namespace

Drupal\Core\Plugin

Code

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

  /** @var \Drupal\Core\Plugin\CategorizingPluginManagerTrait|\Drupal\Component\Plugin\PluginManagerInterface $this */
  $definitions = $this
    ->getSortedDefinitions($definitions ?? $this
    ->getDefinitions(), $label_key);
  $grouped_definitions = [];
  foreach ($definitions as $id => $definition) {
    $grouped_definitions[(string) $definition['category']][$id] = $definition;
  }
  return $grouped_definitions;
}