public function PushIntent::addDependency in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/PushIntent.php \Drupal\cms_content_sync\PushIntent::addDependency()
- 2.0.x src/PushIntent.php \Drupal\cms_content_sync\PushIntent::addDependency()
Push the provided entity as a dependency meaning the referenced entity is available before this entity so it can be referenced on the remote site immediately like bricks or paragraphs.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The referenced entity to push as well
array $details: {@see SyncIntent::getEmbedEntityDefinition}
bool $push_to_same_pool:
Return value
array the definition you can store via {@see SyncIntent::setField} and on the other end receive via {@see SyncIntent::getField}
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
\Drupal\cms_content_sync\Exception\SyncException
\GuzzleHttp\Exception\GuzzleException
1 call to PushIntent::addDependency()
- PushIntent::addReference in src/
PushIntent.php - Push the provided entity as a simple reference. There is no guarantee the referenced entity will be available on the remote site as well, but if it is, it will be de-referenced. If you need the referenced entity to be available, use {
File
- src/
PushIntent.php, line 836
Class
- PushIntent
- Class PushIntent.
Namespace
Drupal\cms_content_syncCode
public function addDependency($entity, $details = null, $push_to_same_pool = true) {
if (in_array($entity
->getEntityTypeId(), ContentSyncSettings::getInstance()
->getEmbedEntities())) {
return $this
->embed($entity, $details);
}
$pools = $this
->pushReference($entity, true, $push_to_same_pool);
// Not pushed? Just using our current pool then to de-reference it at the remote site if the entity exists.
if (empty($pools)) {
return $this->operation
->addDependency($entity
->getEntityTypeId(), $entity
->bundle(), $entity
->uuid(), EntityHandlerPluginManager::isEntityTypeConfiguration($entity
->getEntityType()) ? $entity
->id() : null, Flow::getEntityTypeVersion($entity
->getEntityTypeId(), $entity
->bundle()), $this->pool->id, $details);
}
$result = null;
foreach ($pools as $pool_id) {
$result = $this->operation
->addDependency($entity
->getEntityTypeId(), $entity
->bundle(), $entity
->uuid(), EntityHandlerPluginManager::isEntityTypeConfiguration($entity
->getEntityType()) ? $entity
->id() : null, Flow::getEntityTypeVersion($entity
->getEntityTypeId(), $entity
->bundle()), $pool_id, $details);
}
return $result;
}