You are here

private function ImportEntityManager::compareRevisions in Acquia Content Hub 8

Compare entities by checking if the fields information has changed.

Note: It needs to be a changed entity (has $entity->original).

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check for differences.

Return value

bool TRUE if it finds differences, FALSE otherwise.

1 call to ImportEntityManager::compareRevisions()
ImportEntityManager::entityPresave in src/ImportEntityManager.php
Act on the entity's presave action.

File

src/ImportEntityManager.php, line 222

Class

ImportEntityManager
Provides a service for managing imported entities' actions.

Namespace

Drupal\acquia_contenthub

Code

private function compareRevisions(EntityInterface $entity) {

  // Check if the entity has introduced any local changes.
  $field_comparisons = $this->diffEntityComparison
    ->compareRevisions($entity->original, $entity);
  foreach ($field_comparisons as $field_comparison => $field_comparison_value) {
    list($entity_id, $field_comparison_data) = explode(':', $field_comparison);
    list($entity_type_id, $field_comparison_name) = explode('.', $field_comparison_data);
    if ($entity_id == $entity
      ->id() && $entity_type_id == $entity
      ->getEntityTypeId() && $this
      ->isFieldReferencedToSubclassOf($entity, $field_comparison_name)) {
      continue;
    }
    if ($field_comparison_value['#data']['#left'] !== $field_comparison_value['#data']['#right']) {
      return TRUE;
    }
  }
  return FALSE;
}