You are here

public function ScheduledTransitionsSettingsForm::submitForm in Scheduled Transitions 2.x

Same name and namespace in other branches
  1. 8 src/Form/ScheduledTransitionsSettingsForm.php \Drupal\scheduled_transitions\Form\ScheduledTransitionsSettingsForm::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 ConfigFormBase::submitForm

File

src/Form/ScheduledTransitionsSettingsForm.php, line 277

Class

ScheduledTransitionsSettingsForm
Settings for scheduled transitions.

Namespace

Drupal\scheduled_transitions\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) : void {
  $settings = $this
    ->config('scheduled_transitions.settings')
    ->set('mirror_operations.view scheduled transition', $form_state
    ->getValue('mirror_operation_view'))
    ->set('mirror_operations.add scheduled transition', $form_state
    ->getValue('mirror_operation_add'))
    ->set('mirror_operations.reschedule scheduled transitions', $form_state
    ->getValue('mirror_operation_reschedule'))
    ->set('automation.cron_create_queue_items', (bool) $form_state
    ->getValue('cron_create_queue_items'))
    ->set('message_override', $form_state
    ->getValue('message_override'))
    ->set('message_transition_latest', $form_state
    ->getValue('message_transition_latest'))
    ->set('message_transition_historical', $form_state
    ->getValue('message_transition_historical'))
    ->set('message_transition_copy_latest_draft', $form_state
    ->getValue('message_transition_copy_latest_draft'));
  $settings
    ->clear('bundles');
  foreach (array_keys(array_filter($form_state
    ->getValue('enabled'))) as $index => $enabledBundle) {
    [
      $entityTypeId,
      $bundle,
    ] = explode(':', $enabledBundle);
    $settings
      ->set('bundles.' . $index . '.entity_type', $entityTypeId);
    $settings
      ->set('bundles.' . $index . '.bundle', $bundle);
  }
  $settings
    ->save();
  $this->cacheTagInvalidator
    ->invalidateTags([
    static::SETTINGS_TAG,
  ]);
  parent::submitForm($form, $form_state);
}