You are here

function hook_cer_differences_alter in Corresponding Entity References 8.4

Alters differences found by the CER module, before applying them

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: Entity that hosts entity reference fields to be synchronized.

array $differences: Differences arrary calculated by CorrespondingReference::calculateDifferences()

string $correspondingField: Name of the corresponding field.

See also

\Drupal\cer\Entity\CorrespondingReference::calculateDifferences()

1 invocation of hook_cer_differences_alter()
CorrespondingReference::synchronizeCorrespondingFields in src/Entity/CorrespondingReference.php
Synchronizes corresponding fields on the given entity.

File

./cer.api.php, line 22
Describes hooks and plugins provided by the Corresponding entities references module.

Code

function hook_cer_differences_alter(\Drupal\Core\Entity\ContentEntityInterface $entity, array &$differences, $correspondingField) {

  // Do not synchronize differences if entity is not published.
  if (!$entity
    ->isPublished()) {
    $differences = [
      'add' => [],
      'remove' => [],
    ];
  }
}