You are here

public function ContentExportMultiple::submitForm in Content Synchronization 8.2

Same name and namespace in other branches
  1. 3.0.x src/Form/ContentExportMultiple.php \Drupal\content_sync\Form\ContentExportMultiple::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

src/Form/ContentExportMultiple.php, line 149

Class

ContentExportMultiple
Class ContentExportMultiple

Namespace

Drupal\content_sync\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('confirm') && !empty($this->entityList)) {

    // Delete the content tar file in case an older version exist.
    $this->fileSystem
      ->delete($this
      ->getTempFile());
    $entities_list = [];
    foreach ($this->entityList as $entity_info) {
      $entities_list[] = [
        'entity_type' => $entity_info['entity_type'],
        'entity_id' => $entity_info['entity_id'],
      ];
    }
    if (!empty($entities_list)) {
      $batch = $this
        ->generateBatch($entities_list);
      batch_set($batch);
    }
  }
  else {
    $form_state
      ->setRedirect('system.admin_content');
  }
}