You are here

public function CancelButtonSettingsForm::getEntityTypesToDisplay in Entity Form Cancel Button 8

Gets all the entity types and bundles if applicable for processing.

3 calls to CancelButtonSettingsForm::getEntityTypesToDisplay()
CancelButtonSettingsForm::buildForm in src/Form/CancelButtonSettingsForm.php
Form constructor.
CancelButtonSettingsForm::submitForm in src/Form/CancelButtonSettingsForm.php
Form submission handler.
CancelButtonSettingsForm::validateForm in src/Form/CancelButtonSettingsForm.php
Form validation handler.

File

src/Form/CancelButtonSettingsForm.php, line 299

Class

CancelButtonSettingsForm
Configure generic settings for the Cancel Button.

Namespace

Drupal\cancel_button\Form

Code

public function getEntityTypesToDisplay() {
  $entity_types = $this->entityTypeManager
    ->getDefinitions();
  $entity_types_to_return = [];
  $bundles = [];
  foreach ($entity_types as $entity_type_id => $entity_type) {

    // Do not consider entities with wizard forms.
    if (array_key_exists('wizard', $entity_type
      ->getHandlerClasses())) {
      continue;
    }
    if ($entity_type
      ->hasKey('bundle')) {
      $bundle_entity_type = $entity_type
        ->getBundleEntityType();
      if (!empty($bundle_entity_type)) {
        $bundles[$entity_type_id] = $this->entityTypeManager
          ->getStorage($bundle_entity_type)
          ->loadMultiple();
      }
    }
    $entity_types_to_return[$entity_type_id] = $entity_type;
  }
  return [
    'entity_types' => $entity_types_to_return,
    'bundles' => $bundles,
  ];
}