You are here

function GroupPermissionsForm::submitForm in Group 2.0.x

Same name and namespace in other branches
  1. 8 src/Form/GroupPermissionsForm.php \Drupal\group\Form\GroupPermissionsForm::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/GroupPermissionsForm.php, line 281

Class

GroupPermissionsForm
Provides the group permissions administration form.

Namespace

Drupal\group\Form

Code

function submitForm(array &$form, FormStateInterface $form_state) {
  foreach ($this
    ->getGroupRoles() as $role_name => $group_role) {

    /** @var \Drupal\group\Entity\GroupRoleInterface $group_role */
    $permissions = $form_state
      ->getValue($role_name);
    $group_role
      ->changePermissions($permissions)
      ->trustData()
      ->save();
  }
  $this
    ->messenger()
    ->addStatus($this
    ->t('The changes have been saved.'));
}