diff --git a/src/Entity/CorrespondingReference.php b/src/Entity/CorrespondingReference.php index 3f77ab1..1966b83 100644 --- a/src/Entity/CorrespondingReference.php +++ b/src/Entity/CorrespondingReference.php @@ -248,7 +248,7 @@ class CorrespondingReference extends ConfigEntityBase implements CorrespondingRe continue; } - $differences = $this->calculateDifferences($entity, $fieldName, $deleted); + $differences = $this->calculateDifferences($entity, $fieldName, $deleted, TRUE); $correspondingField = $this->getCorrespondingField($fieldName); // Let other modules alter differences. @@ -365,7 +365,7 @@ class CorrespondingReference extends ConfigEntityBase implements CorrespondingRe * @return array * The differences keyed by 'added' and 'removed'. */ - protected function calculateDifferences(FieldableEntityInterface $entity, $fieldName, $deleted = FALSE) { + protected function calculateDifferences(FieldableEntityInterface $entity, $fieldName, $deleted = FALSE, $addAlways = FALSE) { /** @var FieldableEntityInterface $original */ $original = isset($entity->original) ? $entity->original : NULL; @@ -400,7 +400,7 @@ class CorrespondingReference extends ConfigEntityBase implements CorrespondingRe $originalField = $original->get($fieldName); foreach ($entityField as $fieldItem) { - if (!$this->entityHasValue($original, $fieldName, $fieldItem->target_id)) { + if ($addAlways || !$this->entityHasValue($original, $fieldName, $fieldItem->target_id)) { $differences[CorrespondingReferenceOperations::ADD][] = $fieldItem->entity; } }