protected function AcquiaContentHubEnqueueEntitiesCommands::checkBundleKeyAndInfo in Acquia Content Hub 8.2
Check entity bundle key and info.
Parameters
string $entity_type: The entity type.
string $bundle: The entity bundle.
Return value
mixed Array containing bundle key and bundle info.
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Exception
1 call to AcquiaContentHubEnqueueEntitiesCommands::checkBundleKeyAndInfo()
- AcquiaContentHubEnqueueEntitiesCommands::enqueueEntities in modules/
acquia_contenthub_publisher/ src/ Commands/ AcquiaContentHubEnqueueEntitiesCommands.php - Re-queues entities to Acquia Content Hub.
File
- modules/
acquia_contenthub_publisher/ src/ Commands/ AcquiaContentHubEnqueueEntitiesCommands.php, line 186
Class
- AcquiaContentHubEnqueueEntitiesCommands
- Drush commands for Acquia Content Hub enqueue entities.
Namespace
Drupal\acquia_contenthub_publisher\CommandsCode
protected function checkBundleKeyAndInfo(string $entity_type, string $bundle) {
$bundle_key = $this->entityTypeManager
->getDefinition($entity_type)
->getKey('bundle');
if (empty($bundle_key)) {
throw new \Exception(sprintf('The "%s" entity type does not support bundles.', $entity_type));
}
$bundle_info = $this->entityTypeBundleInfo
->getBundleInfo($entity_type);
if (!in_array($bundle, array_keys($bundle_info))) {
throw new \Exception(sprintf('The bundle "%s" does not exist.', $bundle));
}
return [
$bundle_key => $bundle,
];
}