public function GroupRequestMembershipRejectForm::submitForm in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRejectForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm::submitForm()
- 10.3.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRejectForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm::submitForm()
- 10.0.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRejectForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm::submitForm()
- 10.1.x modules/social_features/social_group/modules/social_group_request/src/Form/GroupRequestMembershipRejectForm.php \Drupal\social_group_request\Form\GroupRequestMembershipRejectForm::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/
social_features/ social_group/ modules/ social_group_request/ src/ Form/ GroupRequestMembershipRejectForm.php, line 156
Class
- GroupRequestMembershipRejectForm
- Provides a confirmation form before rejecting membership.
Namespace
Drupal\social_group_request\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->groupContent
->set('grequest_status', GroupMembershipRequest::REQUEST_REJECTED)
->set('grequest_updated_by', $this->currentUser
->id());
$result = $this->groupContent
->save();
if ($result) {
$this
->messenger()
->addStatus($this
->t('Membership request rejected'));
}
else {
$this
->messenger()
->addError($this
->t('Error updating Request'));
}
$this->cacheTagsInvalidator
->invalidateTags([
'request-membership:' . $this->group
->id(),
]);
$form_state
->setRedirectUrl($this
->getCancelUrl());
}