You are here

protected function ImporterForm::getEntityTypeBundleOptions in CSV Importer 8

Get entity type bundle options.

Parameters

string $entity_type: Entity type.

Return value

array Entity type bundle options.

1 call to ImporterForm::getEntityTypeBundleOptions()
ImporterForm::buildForm in src/Form/ImporterForm.php
Form constructor.

File

src/Form/ImporterForm.php, line 233

Class

ImporterForm
Provides CSV importer form.

Namespace

Drupal\csv_importer\Form

Code

protected function getEntityTypeBundleOptions(string $entity_type) {
  $options = [];
  $entity = $this->entityTypeManager
    ->getDefinition($entity_type);
  if ($entity && ($type = $entity
    ->getBundleEntityType())) {
    $types = $this->entityTypeManager
      ->getStorage($type)
      ->loadMultiple();
    if ($types && is_array($types)) {
      foreach ($types as $type) {
        $options[$type
          ->id()] = $type
          ->label();
      }
    }
  }
  return $options;
}