You are here

public static function MissingDependencyManager::resolveDependencies in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/MissingDependencyManager.php \Drupal\cms_content_sync\MissingDependencyManager::resolveDependencies()
  2. 2.0.x src/MissingDependencyManager.php \Drupal\cms_content_sync\MissingDependencyManager::resolveDependencies()

Resolve any dependencies that were missing before for the given entity that is now available.

Parameters

\Drupal\Core\Entity\EntityInterface $entity:

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

1 call to MissingDependencyManager::resolveDependencies()
PullIntent::resolveMissingDependencies in src/PullIntent.php
Resolve all references to the entity that has just been pulled if they're missing at other content.

File

src/MissingDependencyManager.php, line 93

Class

MissingDependencyManager
Class MissingDependencyManagement.

Namespace

Drupal\cms_content_sync

Code

public static function resolveDependencies($entity) {
  $storage = \Drupal::keyValue(self::COLLECTION_NAME);
  if ('file' === $entity
    ->getEntityTypeId()) {

    /**
     * @var \Drupal\file\Entity\File $entity
     */
    $id = $entity
      ->getEntityTypeId() . ':' . $entity
      ->getFileUri();
    $missing = $storage
      ->get($id);
    if (!empty($missing)) {
      self::saveResolvedDependencies($entity, $missing);
      $storage
        ->delete($id);
    }
  }
  if ($entity instanceof ConfigEntityInterface) {
    $shared_entity_id = $entity
      ->id();
  }
  else {
    $shared_entity_id = $entity
      ->uuid();
  }
  $id = $entity
    ->getEntityTypeId() . ':' . $shared_entity_id;
  $missing = $storage
    ->get($id);
  if (empty($missing)) {
    return;
  }
  self::saveResolvedDependencies($entity, $missing);
  $storage
    ->delete($id);
}