public function EntityConfigSettingsForm::getEntityTypes in Acquia Content Hub 8
Obtains the list of entity types.
File
- src/
Form/ EntityConfigSettingsForm.php, line 426
Class
- EntityConfigSettingsForm
- Defines the form to configure the entity types and bundles to be exported.
Namespace
Drupal\acquia_contenthub\FormCode
public function getEntityTypes() {
$types = $this->entityTypeManager
->getDefinitions();
$entity_types = [];
foreach ($types as $type => $entity) {
// We only support content entity types at the moment, since config
// entities don't implement \Drupal\Core\TypedData\ComplexDataInterface.
if ($entity instanceof ContentEntityType) {
$bundles = $this->entityTypeBundleInfoManager
->getBundleInfo($type);
// Here we need to load all the different bundles?
if (isset($bundles) && count($bundles) > 0) {
foreach ($bundles as $key => $bundle) {
$entity_types[$type][$key] = $bundle['label'];
}
}
else {
// In cases where there are no bundles, but the entity can be
// selected.
$entity_types[$type][$type] = $entity
->getLabel();
}
}
}
return $entity_types;
}