You are here

private function Importer::updateTargetRevisionId in Default Content Deploy 8

If this entity contains a reference field with target revision is value, we should to update it.

Parameters

$decode:

Return value

$this

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to Importer::updateTargetRevisionId()
Importer::preDenormalize in src/Importer.php
This event is triggered before decoding to an entity.

File

src/Importer.php, line 589

Class

Importer
A service for handling import of default content.

Namespace

Drupal\default_content_deploy

Code

private function updateTargetRevisionId(&$decode) {
  if (isset($decode['_embedded'])) {
    foreach ($decode['_embedded'] as $link_key => $link) {
      if (array_column($link, 'target_revision_id')) {
        foreach ($link as $ref_key => $reference) {
          $url = $reference['_links']['type']['href'];
          $uuid = $reference['uuid'][0]['value'];
          $entity_type = $this
            ->getEntityTypeByLink($url);
          $entity = $this->entityRepository
            ->loadEntityByUuid($entity_type, $uuid);

          // Update the Target revision id if child entity exist on this site.
          if ($entity) {
            $revision_id = $entity
              ->getRevisionId();
            $decode['_embedded'][$link_key][$ref_key]['target_revision_id'] = $revision_id;
          }
        }
      }
    }
  }
  return $this;
}