public function bulkDeleteAction(Request $request, Role $role): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'assign'));
        $form = $this->formFactory->deleteRoleAssignments(
            new RoleAssignmentsDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RoleAssignmentsDeleteData $data) use ($role) {
                foreach ($data->getRoleAssignments() as $roleAssignmentId => $selected) {
                    $roleAssignment = $this->roleService->loadRoleAssignment($roleAssignmentId);
                    $this->roleService->removeRoleAssignment($roleAssignment);
                }

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

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

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

        return $this->redirect($this->generateUrl('ezplatform.role.view', [
            'roleId' => $role->id,
        ]));
    }
public function bulkDeleteAction(Request $request, Role $role): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'assign'));
        $form = $this->formFactory->deleteRoleAssignments(
            new RoleAssignmentsDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RoleAssignmentsDeleteData $data) use ($role) {
                foreach ($data->getRoleAssignments() as $roleAssignmentId => $selected) {
                    $roleAssignment = $this->roleService->loadRoleAssignment($roleAssignmentId);
                    $this->roleService->removeRoleAssignment($roleAssignment);
                }

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

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

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

        return $this->redirect($this->generateUrl('ezplatform.role.view', [
            'roleId' => $role->id,
        ]));
    }
public function bulkDeleteAction ( Request $ request , Role $ role ) : Response { $ this -> denyAccessUnlessGranted ( new Attribute ( 'role' , 'assign' ) ) ; $ form = $ this -> formFactory -> deleteRoleAssignments ( new RoleAssignmentsDeleteData ( ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) ) { $ result = $ this -> submitHandler -> handle ( $ form , function ( RoleAssignmentsDeleteData $ data ) use ( $ role ) { foreach ( $ data -> getRoleAssignments ( ) as $ roleAssignmentId => $ selected ) { $ roleAssignment = $ this -> roleService -> loadRoleAssignment ( $ roleAssignmentId ) ; $ this -> roleService -> removeRoleAssignment ( $ roleAssignment ) ; } $ this -> notificationHandler -> success ( $ this -> translator -> trans ( /** @Desc("Assignment on role '%role%' removed.") */ 'role.assignment_delete.success' , [ '%role%' => $ role -> identifier ] , 'role' ) ) ; return new RedirectResponse ( $ this -> generateUrl ( 'ezplatform.role.view' , [ 'roleId' => $ role -> id , ] ) ) ; } ) ; if ( $ result instanceof Response ) { return $ result ; } } return $ this -> redirect ( $ this -> generateUrl ( 'ezplatform.role.view' , [ 'roleId' => $ role -> id , ] ) ) ; }
Handles removing role assignments based on submitted form.

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

@return \Symfony\Component\HttpFoundation\Response
Handles removing role assignments based on submitted form .