You are here

public function WebformOptionsCustomStorage::getCategories in Webform 8.5

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

Gets the names of all categories.

Return value

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

Overrides WebformOptionsCustomStorageInterface::getCategories

File

modules/webform_options_custom/src/WebformOptionsCustomStorage.php, line 23

Class

WebformOptionsCustomStorage
Storage controller class for "webform_options_custom" configuration entities.

Namespace

Drupal\webform_options_custom

Code

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