@param \Symfony\Component\HttpFoundation\Request $request
@param \eZ\Publish\API\Repository\Values\User\Role $role

@return \Symfony\Component\HttpFoundation\Response
777427
public function deleteAction(Request $request, Role $role): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'delete'));
        $form = $this->formFactory->deleteRole(
            new RoleDeleteData($role)
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RoleDeleteData $data) {
                $role = $data->getRole();
                $this->roleService->deleteRole($role);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Role '%role%' removed.") */
                        'role.delete.success',
                        ['%role%' => $role->identifier],
                        'role'
                    )
                );

                return new RedirectResponse($this->generateUrl('ezplatform.role.list'));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->redirect($this->generateUrl('ezplatform.role.view', [
            'roleId' => $role->id,
        ]));
    }
804832
public function update(Role $role)
    {
        $this->validate($this->request, [
            'name'        => 'required',
            'slug'        => 'required|unique:roles,slug,' . $role->id,
        ]);

        $role->name = $this->request->get('name');
        if (! $role->system) {
            $role->slug = $this->request->get('slug');
        }
        $role->save();

        $role->syncPermissions($this->request->get('permissions', []));
        flash()->success('Role ' . $role->name . ' successfully updated!');

        return redirect()->route('administrator.roles.index');
    }
354789
public function deleteRole($role)
    {
        $params = [
            'role' => $role,
        ];

        $body = $this->request(self::URI_AUTH_ROLE_DELETE, $params);

        return $body;
    }
1056221
public function handle($request, Closure $next, $role)
    {
        if (!Auth::user())
        {
            abort(503, "Unauthorized request");
        }

        if (!Auth::user()->hasRole($role))
        {
            abort(503, "Unauthorized request");
        }
        return $next($request);
    }
687427
public function loadPolicies($roleId, Request $request)
    {
        $loadedRole = $this->roleService->loadRole($roleId);

        return new Values\PolicyList($loadedRole->getPolicies(), $request->getPathInfo());
    }
229756
public function hasRole($role)
    {
        $role = strtoupper($role);

        if ($role == 'ROLE_USER') {
            return true;
        }

        if (in_array($role, $this->roles)) {
            return true;
        }

        return false;
    }
134461
public function addRole($username, $role)
    {
        $user = $this->findUserByUsernameOrThrowException($username);
        if ($user->hasRole($role)) {
            return false;
        }

        $user->addRole($role);
        $this->userManager->updateUser($user);

        return true;
    }
102930
public function createAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'create'));
        $form = $this->formFactory->createRole();
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RoleCreateData $data) {
                $roleCreateStruct = $this->roleCreateMapper->reverseMap($data);
                $roleDraft = $this->roleService->createRole($roleCreateStruct);
                $this->roleService->publishRoleDraft($roleDraft);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Role '%role%' created.") */
                        'role.create.success',
                        ['%role%' => $roleDraft->identifier],
                        'role'
                    )
                );

                return new RedirectResponse($this->generateUrl('ezplatform.role.view', [
                    'roleId' => $roleDraft->id,
                ]));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->render('@ezdesign/admin/role/add.html.twig', [
            'form' => $form->createView(),
        ]);
    }
197854
public function getRole($role = null)
    {
        /* @var $roleItem RoleInterface */
        foreach ($this->roles as $roleItem) {
            if ($role == $roleItem->getRole()) {
                return $roleItem;
            }
        }

        return null;
    }
377985
public function remove(Role $role)
    {
        $role->delete();

        Alert::info(__('Role was removed'));

        return redirect()->route('platform.systems.roles');
    }
367988
public function handle($request, Closure $next, $role)
    {
        if (!$this->auth->user()->isRole($role)) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            }

            return abort(401);
        }

        return $next($request);
    }
400190
public function newRole(Role $request)
    {

        $role = $this->addRole($request->input('title'));

        return redirect()
            ->route('configuration.access.roles.edit', ['id' => $role->id])
            ->with('success', trans('web::seat.role_added'));
    }
898450
public function listPlatformRolesGrantableAction(Request $request)
    {
        return new JsonResponse(
            $this->finder->search('Claroline\CoreBundle\Entity\Role', array_merge(
                $request->query->all(),
                ['hiddenFilters' => ['type' => 1, 'grantable' => true]]
            ))
        );
    }
121315
public function addRole(\Amulen\UserBundle\Entity\Role $role)
    {
        $this->roles[] = $role;

        return $this;
    }
479737
public function destroy(Role $role)
    {
        if (! $role->system) {
            try {
                $role->delete();

                return $this->notifySuccess('Role successfully deleted!');
            } catch (QueryException $e) {
                return $this->notifyError($e->getMessage());
            }
        }

        return $this->notifyError('Role is protected and cannot be deleted!');
    }
525890
protected function form(Request $request, Role $role)
    {
        $abilities = $request->user($this->getGuard())->getManagedAbilities();

        return view('cortex/auth::adminarea.pages.role', compact('role', 'abilities'));
    }
181842
public function destroy(Role $role)
    {
        $role->permissions()->detach();
        $role->admins()->detach();
        $role->delete();

        return response()->json(['status' => 1, 'message' => '成功']);
    }