You are here

public function LayoutPluginManager::getCategories in Drupal 9

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

Gets the names of all categories.

Return value

string[] An array of translated categories, sorted alphabetically.

Overrides CategorizingPluginManagerInterface::getCategories

File

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

Class

LayoutPluginManager
Provides a plugin manager for layouts.

Namespace

Drupal\Core\Layout

Code

public function getCategories() {

  // Fetch all categories from definitions and remove duplicates.
  $categories = array_unique(array_values(array_map(function (LayoutDefinition $definition) {
    return $definition
      ->getCategory();
  }, $this
    ->getDefinitions())));
  natcasesort($categories);
  return $categories;
}