You are here

public function WebformOptionsStorage::getCategories in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformOptionsStorage.php \Drupal\webform\WebformOptionsStorage::getCategories()

Gets the names of all categories.

Return value

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

Overrides WebformOptionsStorageInterface::getCategories

File

src/WebformOptionsStorage.php, line 95

Class

WebformOptionsStorage
Storage controller class for "webform_options" configuration entities.

Namespace

Drupal\webform

Code

public function getCategories() {
  $webform_options = $this
    ->loadMultiple();
  $categories = [];
  foreach ($webform_options as $webform_option) {
    if ($category = $webform_option
      ->get('category')) {
      $categories[$category] = $category;
    }
  }
  ksort($categories);
  return $categories;
}