You are here

private function ImportEntityManager::compareReferencedEntities in Acquia Content Hub 8

Compare entities by checking if the entities referenced by it 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::compareReferencedEntities()
ImportEntityManager::entityPresave in src/ImportEntityManager.php
Act on the entity's presave action.

File

src/ImportEntityManager.php, line 180

Class

ImportEntityManager
Provides a service for managing imported entities' actions.

Namespace

Drupal\acquia_contenthub

Code

private function compareReferencedEntities(EntityInterface $entity) {
  $new_references = $entity
    ->referencedEntities();
  $old_references = $entity->original
    ->referencedEntities();
  $new_uuids = array_map([
    $this,
    'excludeCompareReferencedEntities',
  ], $new_references);
  $old_uuids = array_map([
    $this,
    'excludeCompareReferencedEntities',
  ], $old_references);
  $changes = array_diff($new_uuids, $old_uuids);
  if (!empty($changes)) {
    return TRUE;
  }
  return FALSE;
}