You are here

public function PriceListItemExportForm::submitForm in Commerce Pricelist 8.2

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/PriceListItemExportForm.php, line 172

Class

PriceListItemExportForm

Namespace

Drupal\commerce_pricelist\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $batch = [
    'title' => $this
      ->t('Exporting prices'),
    'progress_message' => '',
    'operations' => [],
    'finished' => [
      $this,
      'finishBatch',
    ],
  ];
  $price_list_id = $form_state
    ->get('price_list_id');
  $batch['operations'][] = [
    [
      get_class($this),
      'batchProcess',
    ],
    [
      $this->fileSystem
        ->createFilename("pricelist-{$price_list_id}-prices.csv", 'temporary://'),
      $values['mapping'],
      $values['options'],
      $price_list_id,
    ],
  ];
  batch_set($batch);
  $form_state
    ->setRedirect('entity.commerce_pricelist_item.collection', [
    'commerce_pricelist' => $price_list_id,
  ]);
}