You are here

public function ContentHubCommonActions::getLocalCdfDocument in Acquia Content Hub 8.2

Get a single merged CDF Document of entities and their dependencies.

This is useful for getting a single merged CDFDocument of various entities and all their dependencies. Normally the process of getting a CDFDocument runs through a process that reduces the number of CDFObjects returned based upon data that's been previously syndicated. This function skips that process in order to give a full representation of the entities requested and their dependencies.

Parameters

\Drupal\Core\Entity\EntityInterface ...$entities @codingStandardsIgnoreLine: The entities for which to generate a CDFDocument.

Return value

\Acquia\ContentHubClient\CDFDocument The CDFDocument object.

Throws

\Exception

File

src/ContentHubCommonActions.php, line 117

Class

ContentHubCommonActions
Common actions across the entirety of Content Hub.

Namespace

Drupal\acquia_contenthub

Code

public function getLocalCdfDocument(EntityInterface ...$entities) {

  //@codingStandardsIgnoreLine
  $document = new CDFDocument();
  $wrappers = [];
  foreach ($entities as $entity) {
    $entityDocument = new CDFDocument(...array_values($this
      ->getEntityCdf($entity, $wrappers, FALSE)));
    $document
      ->mergeDocuments($entityDocument);
  }
  return $document;
}