You are here

public function EntityManager::getAllowedEntityTypes in Acquia Content Hub 8

Obtains the list of entity types.

File

src/EntityManager.php, line 711

Class

EntityManager
Provides a service for managing entity actions for Content Hub.

Namespace

Drupal\acquia_contenthub

Code

public function getAllowedEntityTypes() {

  // List of entities that are excluded from displaying on
  // entity configuration page and will not be pushed to Content Hub.
  $excluded_types = $this
    ->getExcludedContentEntityTypeIds();
  $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 ContentEntityTypeInterface) {

      // Skip excluded types.
      if (in_array($type, $excluded_types)) {
        continue;
      }
      $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'];
        }
      }
    }
  }
  $entity_types = array_diff_key($entity_types, $excluded_types);
  return $entity_types;
}