You are here

public function WebformOptionsStorage::getOptions in Webform 8.5

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

Get all options grouped by category.

Return value

string[] An array of options grouped by category.

Overrides WebformOptionsStorageInterface::getOptions

File

src/WebformOptionsStorage.php, line 110

Class

WebformOptionsStorage
Storage controller class for "webform_options" configuration entities.

Namespace

Drupal\webform

Code

public function getOptions() {
  $webform_options = $this
    ->loadMultiple();
  @uasort($webform_options, [
    $this->entityType
      ->getClass(),
    'sort',
  ]);
  $uncategorized_options = [];
  $categorized_options = [];
  foreach ($webform_options as $id => $webform_option) {
    if ($category = $webform_option
      ->get('category')) {
      $categorized_options[$category][$id] = $webform_option
        ->label();
    }
    else {
      $uncategorized_options[$id] = $webform_option
        ->label();
    }
  }
  return $uncategorized_options + $categorized_options;
}