public function EventTypeAccessDefaultsForm::save in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/Form/EventTypeAccessDefaultsForm.php \Drupal\rng\Form\EventTypeAccessDefaultsForm::save()
- 8 src/Form/EventTypeAccessDefaultsForm.php \Drupal\rng\Form\EventTypeAccessDefaultsForm::save()
Form submission handler for the 'save' action.
Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Overrides EntityForm::save
File
- src/
Form/ EventTypeAccessDefaultsForm.php, line 293
Class
- EventTypeAccessDefaultsForm
- Form for event type access defaults.
Namespace
Drupal\rng\FormCode
public function save(array $form, FormStateInterface $form_state) {
/** @var \Drupal\rng\Entity\EventTypeInterface $event_type */
$event_type = $this->entity;
$registration_operations = $form_state
->getValue([
'actions',
'operations',
]);
foreach ($this->rules as $rule) {
$rule
->setAction('registration_operations', [
'id' => 'registration_operations',
'configuration' => [
'operations' => $registration_operations[$rule
->getMachineName()],
],
]);
$rule
->save();
}
$event_type
->setAllowCustomRules($form_state
->getValue('custom_rules'))
->save();
// Site cache needs to be cleared after enabling this setting as there are
// issue regarding caching.
// For some reason actions access is not reset if pages are rendered with no
// access/viability.
Cache::invalidateTags([
'rendered',
]);
$this
->messenger()
->addMessage($this
->t('Event type access defaults saved.'));
$this->eventManager
->invalidateEventType($event_type);
}