You are here

protected function ESQueryGenerator::getSubscriberSupportedEntityBundles in Acquia Content Hub 8

Obtains a list of supported entity bundles.

1 call to ESQueryGenerator::getSubscriberSupportedEntityBundles()
ESQueryGenerator::getElasticSearchQuery in acquia_contenthub_subscriber/src/ESQueryGenerator.php
Obtains an Elasticsearch Query.

File

acquia_contenthub_subscriber/src/ESQueryGenerator.php, line 159

Class

ESQueryGenerator
Elasticsearch query generator.

Namespace

Drupal\acquia_contenthub_subscriber

Code

protected function getSubscriberSupportedEntityBundles() {

  /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
  $entity_manager = \Drupal::getContainer()
    ->get('acquia_contenthub.entity_manager');

  /** @var \Drupal\acquia_contenthub\EntityManager $entity_manager */
  $entity_type_manager = \Drupal::entityTypeManager();
  $entity_types = $entity_manager
    ->getAllowedEntityTypes();
  $entity_types_and_bundles = [];
  foreach ($entity_types as $entity_type => $bundles) {
    if ($entity_type === 'taxonomy_term') {
      $bundle_key = 'vocabulary';
    }
    else {
      $bundle_key = $entity_type_manager
        ->getDefinition($entity_type)
        ->getKey('bundle');
    }
    $entity_types_and_bundles[$entity_type] = [
      'bundle_key' => $bundle_key,
      'bundles' => array_keys($bundles),
    ];
  }
  return $entity_types_and_bundles;
}