function LayoutPluginManager::getCategories

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Layout/LayoutPluginManager.php \Drupal\Core\Layout\LayoutPluginManager::getCategories()
  2. 8.9.x core/lib/Drupal/Core/Layout/LayoutPluginManager.php \Drupal\Core\Layout\LayoutPluginManager::getCategories()
  3. 11.x 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;
}

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