You are here

public function BlazyAdminBase::getOptionsetOptions in Blazy 8

Same name and namespace in other branches
  1. 8.2 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::getOptionsetOptions()
  2. 7 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::getOptionsetOptions()

Returns available optionsets for select options.

File

src/Form/BlazyAdminBase.php, line 696

Class

BlazyAdminBase
A base for blazy admin integration to have re-usable methods in one place.

Namespace

Drupal\blazy\Form

Code

public function getOptionsetOptions($entity_type = '') {
  $optionsets = [];
  if (empty($entity_type)) {
    return $optionsets;
  }
  $entities = $this->blazyManager
    ->entityLoadMultiple($entity_type);
  foreach ((array) $entities as $entity) {
    $optionsets[$entity
      ->id()] = Html::escape($entity
      ->label());
  }
  asort($optionsets);
  return $optionsets;
}