You are here

public function ContentEntityConflictHandler::finishConflictResolution in Conflict 8.2

Finishes the conflict resolution after the user interaction (manual merge).

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

array $path_parents: The parents to the entity.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides EntityConflictHandlerInterface::finishConflictResolution

File

src/Entity/ContentEntityConflictHandler.php, line 674

Class

ContentEntityConflictHandler

Namespace

Drupal\conflict\Entity

Code

public function finishConflictResolution(EntityInterface $entity, $path_parents, FormStateInterface $form_state) {

  // Exchange the original entity with the server one as after the user
  // interaction (manual merge) the current entity has as origin the server
  // entity.
  $entity_server = $entity->{static::CONFLICT_ENTITY_SERVER};
  $entity->{static::CONFLICT_ENTITY_ORIGINAL} = $entity_server;
  $entity_server_hash = $entity_server->{static::CONFLICT_ENTITY_ORIGINAL_HASH};
  $entity->{static::CONFLICT_ENTITY_ORIGINAL_HASH} = $entity_server_hash;

  // Flag the entity that it doesn't need a manual merge anymore.
  $entity->{static::CONFLICT_ENTITY_NEEDS_MANUAL_MERGE} = FALSE;

  // Exchange the original entity's hash value in the user input as well to be
  // prepared for next submits in case the form isn't submitted immediately,
  // but the work is continued.
  $input =& $form_state
    ->getUserInput();
  $hash_path_parents = $path_parents;
  $hash_path_parents[] = 'conflict_entity_original_hash';
  NestedArray::setValue($input, $hash_path_parents, $entity_server_hash);
}