You are here

public function SmartDateOverrideForm::submitForm in Smart Date 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::submitForm()
  2. 3.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::submitForm()
  3. 3.1.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::submitForm()
  4. 3.2.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::submitForm()
  5. 3.3.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::submitForm()
  6. 3.4.x modules/smart_date_recur/src/Form/SmartDateOverrideForm.php \Drupal\smart_date_recur\Form\SmartDateOverrideForm::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/smart_date_recur/src/Form/SmartDateOverrideForm.php, line 167

Class

SmartDateOverrideForm
Form controller for Smart Date Recur instace override edit forms.

Namespace

Drupal\smart_date_recur\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->override($form_state);
  if (!isset($form['ajaxcancel'])) {

    /* @var \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager */
    $entityTypeManager = \Drupal::service('entity_type.manager');

    /* @var \Drupal\smart_date_recur\Entity\SmartDateRule $rrule */
    $rrule = $entityTypeManager
      ->getStorage('smart_date_rule')
      ->load($form_state
      ->getValue('rrule'));
    $instanceController = new Instances();

    // Force refresh of parent entity.
    $instanceController
      ->applyChanges($rrule);

    // Output message about operation performed, if not using AJAX.
    $this
      ->messenger()
      ->addMessage($this
      ->t('The instance has been rescheduled.'));
  }

  // Redirect to rrule instance listing.
  $form_state
    ->setRedirect('smart_date_recur.instances', [
    'rrule' => $form_state
      ->getValue('rrule'),
  ]);
}