public static function MissingDependencyManager::saveUnresolvedDependency in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/MissingDependencyManager.php \Drupal\cms_content_sync\MissingDependencyManager::saveUnresolvedDependency()
- 2.0.x src/MissingDependencyManager.php \Drupal\cms_content_sync\MissingDependencyManager::saveUnresolvedDependency()
Save that an entity dependency could not be resolved so it triggers its pull automatically whenever it can be resolved.
Parameters
string $referenced_entity_type:
string $referenced_entity_shared_id:
\Drupal\Core\Entity\EntityInterface $entity:
string $reason:
null|string $field:
null|array $custom_data:
2 calls to MissingDependencyManager::saveUnresolvedDependency()
- DefaultCropHandler::pull in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultCropHandler.php - Pull the remote entity.
- PullIntent::saveUnresolvedDependency in src/
PullIntent.php - Mark the given dependency as missing so it's automatically resolved whenever it gets pulled.
File
- src/
MissingDependencyManager.php, line 47
Class
- MissingDependencyManager
- Class MissingDependencyManagement.
Namespace
Drupal\cms_content_syncCode
public static function saveUnresolvedDependency($referenced_entity_type, $referenced_entity_shared_id, $entity, $reason, $field = null, $custom_data = null) {
$storage = \Drupal::keyValue(self::COLLECTION_NAME);
$id = $referenced_entity_type . ':' . $referenced_entity_shared_id;
$missing = $storage
->get($id);
if (empty($missing)) {
$missing = [];
}
// Skip if that entity has already been added (referencing the same entity multiple times)
foreach ($missing as $sync) {
if ($sync[self::INDEX_ENTITY_TYPE] === $entity
->getEntityTypeId() && $sync[self::INDEX_ENTITY_ID] === $entity
->uuid() && (isset($sync[self::INDEX_SET_FIELD]) ? $sync[self::INDEX_SET_FIELD] : null) === $field) {
return;
}
}
$data = [
self::INDEX_ENTITY_TYPE => $entity
->getEntityTypeId(),
self::INDEX_ENTITY_ID => $entity
->uuid(),
self::INDEX_PULL_REASON => $reason,
];
if ($field) {
$data[self::INDEX_SET_FIELD] = $field;
}
if ($custom_data) {
$data[self::INDEX_DATA] = $custom_data;
}
$missing[] = $data;
$storage
->set($id, $missing);
}