You are here

public function EventAccessResetForm::submitForm in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Form/EventAccessResetForm.php \Drupal\rng\Form\EventAccessResetForm::submitForm()
  2. 3.x src/Form/EventAccessResetForm.php \Drupal\rng\Form\EventAccessResetForm::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

src/Form/EventAccessResetForm.php, line 136

Class

EventAccessResetForm
Form controller to reset event access to defaults.

Namespace

Drupal\rng\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($rules = $this->eventMeta
    ->getRules('rng_event.register')) {
    foreach ($rules as $rule) {
      $rule
        ->delete();
    }
    drupal_set_message($this
      ->t('Access rules reset to site defaults.'));
  }
  else {
    $this->eventMeta
      ->addDefaultAccess();
    drupal_set_message($this
      ->t('Access rules can now be customized using edit operations.'));
  }
  Cache::invalidateTags($this->event
    ->getCacheTagsToInvalidate());
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}