You are here

public function DiscoveryInterfaceController::getSupportedEntityTypesAndBundles in Acquia Content Hub 8.2

Obtains a list of supported entity types and bundles by this site.

This also includes the 'bundle' key field. If the bundle key is empty this means that this entity does not have any bundle information.

@todo This needs to be changed in the discovery interface to see all types.

Return value

array An array of entity_types and bundles keyed by entity_type.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to DiscoveryInterfaceController::getSupportedEntityTypesAndBundles()
DiscoveryInterfaceController::loadDiscovery in modules/acquia_contenthub_curation/src/Controller/DiscoveryInterfaceController.php
Loads the content hub discovery page from an ember app.

File

modules/acquia_contenthub_curation/src/Controller/DiscoveryInterfaceController.php, line 157

Class

DiscoveryInterfaceController
Controller for Content Hub Discovery page.

Namespace

Drupal\acquia_contenthub_curation\Controller

Code

public function getSupportedEntityTypesAndBundles() {
  $entity_type_bundles = $this->bundleInfoManager
    ->getAllBundleInfo();
  $entity_types_and_bundles = [];
  foreach ($entity_type_bundles as $entity_type => $bundles) {
    $bundle_key = '';
    if ($entity_type === 'taxonomy_term') {
      $bundle_key = 'vocabulary';
    }
    else {
      $bundle_key = $this->entityTypeManager
        ->getDefinition($entity_type)
        ->getKey('bundle');
    }

    // For now, if there is no bundle key (config entity), skip.
    if ($bundle_key == '') {
      continue;
    }
    $entity_types_and_bundles[$entity_type] = [
      'bundle_key' => $bundle_key,
      'bundles' => array_keys($bundles),
    ];
  }
  return $entity_types_and_bundles;
}