public function ContentHubEntityExportController::getDrupalEntities in Acquia Content Hub 8
Collects all Drupal Entities that needs to be sent to Hub.
Throws
\Drupal\Core\Entity\EntityStorageException
1 string reference to 'ContentHubEntityExportController::getDrupalEntities'
File
- src/
Controller/ ContentHubEntityExportController.php, line 223
Class
- ContentHubEntityExportController
- Controller for Content Hub Export Entities using bulk upload.
Namespace
Drupal\acquia_contenthub\ControllerCode
public function getDrupalEntities() {
$normalized = [
'entities' => [],
];
$normalized_entities = [];
// phpcs:ignore
$entities = $_GET;
foreach ($entities as $entity => $entity_ids) {
$ids = explode(',', $entity_ids);
foreach ($ids as $id) {
$id = trim($id);
try {
$bulk_cdf = $this->internalRequest
->getEntityCDFByInternalRequest($entity, $id);
$bulk_cdf = array_pop($bulk_cdf);
if (is_array($bulk_cdf)) {
foreach ($bulk_cdf as $cdf) {
$normalized_entities[$cdf['uuid']] = $cdf;
}
}
} catch (\Exception $e) {
// Do nothing, route does not exist, but report it.
$args = [
'@type' => $entity,
'@id' => $id,
'@msg' => $e
->getMessage(),
];
$this->loggerFactory
->get('acquia_contenthub')
->error('Could not obtain the CDF for entity (@type, @id) : @msg', $args);
}
}
}
// If we reach here, then there was no error processing the sub-requests.
// Save all entities in the tracking entities and return the response.
$normalized['entities'] = array_values($normalized_entities);
if ($this
->isRequestFromAcquiaContentHub()) {
foreach ($normalized['entities'] as $cdf) {
$this
->trackExportedEntity($cdf, TRUE);
}
}
return JsonResponse::create($normalized);
}