You are here

function _rac_form_user_role_form_submit in Role Access Control 8

Same name and namespace in other branches
  1. 8.2 rac.module \_rac_form_user_role_form_submit()

Implements hook_submit().

Handle submission of role form to grant access permission for own content.

1 string reference to '_rac_form_user_role_form_submit'
rac_form_user_role_form_alter in ./rac.module
Implements hook_form_FORM_ID_alter().

File

./rac.module, line 151
Module providing role access relations.

Code

function _rac_form_user_role_form_submit(&$form, FormStateInterface $form_state) {
  $role = $form_state
    ->getFormObject()
    ->getEntity();
  $permission = "RAC_view_" . $role
    ->id();
  if (!$role
    ->hasPermission($permission)) {
    $role
      ->grantPermission($permission);
    $role
      ->save();
  }
}