public function ImportForm::submitForm in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_import/src/Form/ImportForm.php \Drupal\bibcite_import\Form\ImportForm::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_import/ src/ Form/ ImportForm.php, line 122 
Class
- ImportForm
- Common import form.
Namespace
Drupal\bibcite_import\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
  $format_id = $form_state
    ->getValue('format');
  /** @var \Drupal\bibcite\Plugin\BibciteFormatInterface $format */
  $format = $this->formatManager
    ->createInstance($format_id);
  $decoded = $form_state
    ->getValue('decoded');
  $chunks = array_chunk($decoded, 50);
  $batch = [
    'title' => t('Import reference data'),
    'operations' => [],
    'finished' => 'bibcite_import_batch_finished',
    'file' => drupal_get_path('module', 'bibcite_import') . '/bibcite_import.batch.inc',
  ];
  foreach ($chunks as $chunk) {
    $batch['operations'][] = [
      'bibcite_import_batch_callback',
      [
        $chunk,
        $format,
      ],
    ];
  }
  batch_set($batch);
}