You are here

public function ContentUploadConfirmForm::submitForm in GatherContent 8.3

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 ContentConfirmForm::submitForm

File

src/Form/ContentUploadConfirmForm.php, line 60

Class

ContentUploadConfirmForm
Provides a node deletion confirmation form.

Namespace

Drupal\gathercontent\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('confirm') && !empty($this->nodeIds)) {
    $operation = Operation::create([
      'type' => 'upload',
    ]);
    $operation
      ->save();
    $nodes = Node::loadMultiple($this->nodeIds);
    $operations = [];
    foreach ($nodes as $node) {
      $operations[] = [
        'gathercontent_upload_process',
        [
          $node,
          $operation
            ->uuid(),
        ],
      ];
    }
    $batch = [
      'title' => t('Uploading content ...'),
      'operations' => $operations,
      'finished' => 'gathercontent_upload_finished',
      'init_message' => t('Upload is starting ...'),
      'progress_message' => t('Processed @current out of @total.'),
      'error_message' => t('An error occurred during processing'),
    ];
    $this->tempStore
      ->delete('nodes');
    batch_set($batch);
  }
}