You are here

public function ConflictResolutionDialogFormBuilder::resolveConflictsSubmit in Conflict 8.2

Submit handler for starting the conflict resolution.

Parameters

$form: The form array.

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

File

src/Form/ConflictResolutionDialogFormBuilder.php, line 116

Class

ConflictResolutionDialogFormBuilder

Namespace

Drupal\conflict\Form

Code

public function resolveConflictsSubmit($form, FormStateInterface $form_state) {

  // First entity to process.
  if ($form_state
    ->get('conflict.build_conflict_resolution_form')) {

    // Reset the flag for building the overview form.
    $form_state
      ->set('conflict.build_conflict_resolution_form', FALSE);
    $form_state
      ->set('conflict.processing', TRUE);
    $form_state
      ->set('conflict.first_processing', TRUE);
  }
  else {
    $form_state
      ->set('conflict.first_processing', FALSE);
  }
  $conflict_paths = $form_state
    ->get('conflict.paths');
  if ($conflict_paths) {
    reset($conflict_paths);
    $path = key($conflict_paths);
    unset($conflict_paths[$path]);
    $form_state
      ->set('conflict.paths', $conflict_paths);
    $form_state
      ->set('conflict.processing_path', $path);
  }
  else {

    // Finish the conflict resolution for the entity that has been just
    // processed through the user interaction.
    $path = $form_state
      ->get('conflict.processing_path');
    $path_entities = static::getEntitiesForPropertyPath($path, $form_state);
    $path_entity = end($path_entities);
    $path_parents = explode('.', $path);
    $this
      ->getEntityConflictHandler($path_entity
      ->getEntityTypeId())
      ->finishConflictResolution($path_entity, $path_parents, $form_state);
    $form_state
      ->set('conflict.processing', FALSE);
    $form_state
      ->set('conflict.processing_path', NULL);
  }
  $form_state
    ->setCached();
}