You are here

public function CronConfigForm::submitForm in Commerce Stock 8

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

File

modules/local_storage/src/Form/CronConfigForm.php, line 119

Class

CronConfigForm
Class CronConfigForm.

Namespace

Drupal\commerce_stock_local\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Get the transaction haqndling form values.
  $transactions_aggregation_mode = $form_state
    ->getValue('aggregation_mode');
  $transactions_retention = $form_state
    ->getValue('transactions_retention');

  // Set the submitted configuration setting.
  $this->configFactory
    ->getEditable('commerce_stock_local.transactions')
    ->set('transactions_aggregation_mode', $transactions_aggregation_mode)
    ->set('transactions_retention', $transactions_retention)
    ->save();

  // Get the cron form values.
  $update_batch_size = $form_state
    ->getValue('update_batch_size');
  $update_interval = $form_state
    ->getValue('update_interval');
  $cron_run_mode = $form_state
    ->getValue('cron_run_mode');
  $reset_update_last_id = $form_state
    ->getValue('reset_update_last_id');

  // Set the submitted configuration setting.
  $this->configFactory
    ->getEditable('commerce_stock_local.cron')
    ->set('update_batch_size', $update_batch_size)
    ->set('update_interval', $update_interval)
    ->set('cron_run_mode', $cron_run_mode)
    ->save();
  if ($reset_update_last_id) {
    \Drupal::state()
      ->set('commerce_stock_local.update_last_id', 0);
  }
  parent::submitForm($form, $form_state);
}