You are here

public function ImportEntityManager::entityUpdate in Acquia Content Hub 8

Act on the entity's update action.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity that is being updated.

File

src/ImportEntityManager.php, line 899

Class

ImportEntityManager
Provides a service for managing imported entities' actions.

Namespace

Drupal\acquia_contenthub

Code

public function entityUpdate(EntityInterface $entity) {

  // Early return, if already sync'ing.
  if (!empty($entity->__contenthub_entity_syncing)) {
    return;
  }
  $imported_entity = $this->contentHubEntitiesTracking
    ->loadImportedByDrupalEntity($entity
    ->getEntityTypeId(), $entity
    ->id());

  // Early return, if not an imported entity or not pending sync.
  if (!$imported_entity || !$imported_entity
    ->isPendingSync()) {
    return;
  }

  // Otherwise, re-import the entity.
  $this
    ->importRemoteEntity($imported_entity
    ->getUuid(), $entity);
}