You are here

public function MergeMultipleForm::submitForm in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/Form/MergeMultipleForm.php \Drupal\bibcite_entity\Form\MergeMultipleForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormInterface::submitForm

File

modules/bibcite_entity/src/Form/MergeMultipleForm.php, line 157

Class

MergeMultipleForm
Merge multiple bibliographic entities into one.

Namespace

Drupal\bibcite_entity\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $target_id = $form_state
    ->getValue('target');
  $operations = [];
  foreach ($this->entityInfo as $id => $label) {
    $operations[] = [
      'bibcite_entity_merge_entity',
      [
        $id,
        $target_id,
        $this->entityType
          ->id(),
        $this->fieldName,
      ],
    ];
    $operations[] = [
      'bibcite_entity_merge_entity_delete',
      [
        $id,
        $this->entityType
          ->id(),
        $this->fieldName,
      ],
    ];
  }
  $batch = [
    'title' => t('Merging'),
    'operations' => $operations,
    'finished' => 'bibcite_entity_merge_entity_finished',
    'file' => drupal_get_path('module', 'bibcite_entity') . '/bibcite_entity.batch.inc',
  ];
  batch_set($batch);
  $this->tempStore
    ->delete($this->currentUser
    ->id());
}