You are here

public function ContentHubCommonActions::getCdfDocument in Acquia Content Hub 8.2

Retrieves entities and dependencies by uuid and returns a CDFDocument.

Parameters

string ...$uuids @codingStandardsIgnoreLine: The list of uuids to retrieve.

Return value

\Acquia\ContentHubClient\CDFDocument The CDFDocument object.

Throws

\Drupal\acquia_contenthub_subscriber\Exception\ContentHubImportException

1 call to ContentHubCommonActions::getCdfDocument()
ContentHubCommonActions::importEntities in src/ContentHubCommonActions.php
Import a group of entities by their uuids from the ContentHub Service.

File

src/ContentHubCommonActions.php, line 210

Class

ContentHubCommonActions
Common actions across the entirety of Content Hub.

Namespace

Drupal\acquia_contenthub

Code

public function getCdfDocument(string ...$uuids) {

  //@codingStandardsIgnoreLine
  $uuid_list = [];
  foreach ($uuids as $uuid) {
    if (!Uuid::isValid($uuid)) {
      $exception = new ContentHubImportException(sprintf("Invalid uuid %s.", $uuid), 101);
      $exception
        ->setUuids([
        $uuid,
      ]);
      throw $exception;
    }
    $uuid_list[$uuid] = $uuid;
  }
  $document = $this
    ->getClient()
    ->getEntities($uuid_list);
  $this
    ->validateDocument($document, $uuid_list);
  $missing_dependencies = $this
    ->getMissingDependencies($document);
  $client = $this
    ->getClient();
  while ($missing_dependencies) {
    $document
      ->mergeDocuments($client
      ->getEntities($missing_dependencies));
    $uuid_list += $missing_dependencies;
    $this
      ->validateDocument($document, $uuid_list);
    $missing_dependencies = $this
      ->getMissingDependencies($document);
  }
  return $document;
}