public function bulkDeleteAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'delete'));
        $form = $this->formFactory->deleteRoles(
            new RolesDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RolesDeleteData $data) {
                foreach ($data->getRoles() as $roleId => $selected) {
                    $role = $this->roleService->loadRole($roleId);
                    $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 new RedirectResponse($this->generateUrl('ezplatform.role.list'));
    }
public function bulkDeleteAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'delete'));
        $form = $this->formFactory->deleteRoles(
            new RolesDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RolesDeleteData $data) {
                foreach ($data->getRoles() as $roleId => $selected) {
                    $role = $this->roleService->loadRole($roleId);
                    $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 new RedirectResponse($this->generateUrl('ezplatform.role.list'));
    }
public function bulkDeleteAction ( Request $ request ) : Response { $ this -> denyAccessUnlessGranted ( new Attribute ( 'role' , 'delete' ) ) ; $ form = $ this -> formFactory -> deleteRoles ( new RolesDeleteData ( ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) ) { $ result = $ this -> submitHandler -> handle ( $ form , function ( RolesDeleteData $ data ) { foreach ( $ data -> getRoles ( ) as $ roleId => $ selected ) { $ role = $ this -> roleService -> loadRole ( $ roleId ) ; $ 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 new RedirectResponse ( $ this -> generateUrl ( 'ezplatform.role.list' ) ) ; }
Handles removing roles based on submitted form.

@param Request $request

@return Response

@throws \InvalidArgumentException
@throws InvalidArgumentException
@throws InvalidOptionsException
Handles removing roles based on submitted form .