function navigation_post_update_update_permissions

Same name in other branches
  1. 11.x core/modules/navigation/navigation.post_update.php \navigation_post_update_update_permissions()

Grants navigation specific permission to roles with access to any layout.

File

core/modules/navigation/navigation.post_update.php, line 14

Code

function navigation_post_update_update_permissions(array &$sandbox) {
    \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'user_role', function (RoleInterface $role) {
        $needs_save = FALSE;
        if ($role->hasPermission('configure any layout')) {
            $role->grantPermission('configure navigation layout');
            $needs_save = TRUE;
        }
        if ($role->hasPermission('administer navigation_block')) {
            $role->revokePermission('administer navigation_block');
            $role->grantPermission('configure navigation layout');
            $needs_save = TRUE;
        }
        return $needs_save;
    });
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.