You are here

private function ImportEntityManager::getAllRemoteDependencies in Acquia Content Hub 8

Obtains all dependencies for the current Content Hub Entity.

It collects dependencies on all levels, flattening out the dependency array to avoid looping circular dependencies.

Parameters

\Drupal\acquia_contenthub\ContentHubEntityDependency $content_hub_entity: The Content Hub Entity.

array $dependencies: An array of \Drupal\acquia_contenthub\ContentHubEntityDependency.

bool|true $use_chain: If the dependencies should be unique to the dependency chain or not.

Return value

array An array of \Drupal\acquia_contenthub\ContentHubEntityDependency.

1 call to ImportEntityManager::getAllRemoteDependencies()
ImportEntityManager::importRemoteEntity in src/ImportEntityManager.php
Saves a Content Hub Entity into a Drupal Entity, given its UUID.

File

src/ImportEntityManager.php, line 338

Class

ImportEntityManager
Provides a service for managing imported entities' actions.

Namespace

Drupal\acquia_contenthub

Code

private function getAllRemoteDependencies(ContentHubEntityDependency $content_hub_entity, array &$dependencies, $use_chain = TRUE) {

  // Obtaining dependencies of this entity.
  $dep_dependencies = $this
    ->getRemoteDependencies($content_hub_entity, $use_chain);

  /** @var \Drupal\acquia_contenthub\ContentHubEntityDependency $content_hub_dependency */
  foreach ($dep_dependencies as $uuid => $content_hub_dependency) {
    if (isset($dependencies[$uuid])) {
      continue;
    }

    // Also check if this dependency has been 1) previously imported, 2) is an
    // independent entity, and 3) has the same modified timestamp. If the
    // 'modified' timestamp matches, then we know we are trying to import an
    // entity that has no change, then it does not need to be imported again.
    $imported_entity = $this->contentHubEntitiesTracking
      ->loadImportedByUuid($uuid);
    if ($imported_entity && !$imported_entity
      ->isDependent() && $imported_entity
      ->getModified() === $content_hub_dependency
      ->getRawEntity()
      ->getModified()) {
      continue;
    }
    $dependencies[$uuid] = $content_hub_dependency;
    $this
      ->getAllRemoteDependencies($content_hub_dependency, $dependencies, $use_chain);
  }
  return array_reverse($dependencies, TRUE);
}