function file_post_update_add_permissions_to_roles

Grant all non-anonymous roles the 'delete own files' permission.

File

core/modules/file/file.post_update.php, line 23

Code

function file_post_update_add_permissions_to_roles(?array &$sandbox = NULL) : void {
    \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'user_role', function (RoleInterface $role) : bool {
        if ($role->id() === RoleInterface::ANONYMOUS_ID || $role->isAdmin()) {
            return FALSE;
        }
        $role->grantPermission('delete own files');
        return TRUE;
    });
}

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