You are here

public function MergeRemoteOnlyChanges::resolveConflictsContentEntity in Conflict 8.2

Resolves conflicts on content entities.

Parameters

\Drupal\conflict\Event\EntityConflictResolutionEvent: The entity conflict discovery event.

Overrides MergeStrategyInterface::resolveConflictsContentEntity

File

src/ConflictResolution/MergeRemoteOnlyChanges.php, line 20

Class

MergeRemoteOnlyChanges

Namespace

Drupal\conflict\ConflictResolution

Code

public function resolveConflictsContentEntity(EntityConflictResolutionEvent $event) {

  /** @var \Drupal\Core\Entity\ContentEntityInterface $remote_entity */
  $remote_entity = $event
    ->getRemoteEntity();

  /** @var \Drupal\Core\Entity\ContentEntityInterface $result_entity */
  $result_entity = $event
    ->getResultEntity();
  foreach ($event
    ->getConflicts() as $property => $conflict_type) {
    if ($conflict_type === ConflictTypes::CONFLICT_TYPE_REMOTE) {
      $result_entity
        ->set($property, $remote_entity
        ->get($property)
        ->getValue());
      $event
        ->removeConflict($property);
    }
  }
}