public function bulkDeleteAction(Request $request, ContentTypeGroup $group): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('class', 'delete'));
        $form = $this->formFactory->deleteContentTypes(
            new ContentTypesDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentTypesDeleteData $data) {
                foreach ($data->getContentTypes() as $contentTypeId => $selected) {
                    $contentType = $this->contentTypeService->loadContentType($contentTypeId);

                    $this->contentTypeService->deleteContentType($contentType);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Content Type '%name%' deleted.") */
                            'content_type.delete.success',
                            ['%name%' => $contentType->getName()],
                            'content_type'
                        )
                    );
                }
            });

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

        return $this->redirect($this->generateUrl('ezplatform.content_type_group.view', ['contentTypeGroupId' => $group->id]));
    }
public function bulkDeleteAction(Request $request, ContentTypeGroup $group): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('class', 'delete'));
        $form = $this->formFactory->deleteContentTypes(
            new ContentTypesDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentTypesDeleteData $data) {
                foreach ($data->getContentTypes() as $contentTypeId => $selected) {
                    $contentType = $this->contentTypeService->loadContentType($contentTypeId);

                    $this->contentTypeService->deleteContentType($contentType);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Content Type '%name%' deleted.") */
                            'content_type.delete.success',
                            ['%name%' => $contentType->getName()],
                            'content_type'
                        )
                    );
                }
            });

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

        return $this->redirect($this->generateUrl('ezplatform.content_type_group.view', ['contentTypeGroupId' => $group->id]));
    }
public function bulkDeleteAction ( Request $ request , ContentTypeGroup $ group ) : Response { $ this -> denyAccessUnlessGranted ( new Attribute ( 'class' , 'delete' ) ) ; $ form = $ this -> formFactory -> deleteContentTypes ( new ContentTypesDeleteData ( ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) ) { $ result = $ this -> submitHandler -> handle ( $ form , function ( ContentTypesDeleteData $ data ) { foreach ( $ data -> getContentTypes ( ) as $ contentTypeId => $ selected ) { $ contentType = $ this -> contentTypeService -> loadContentType ( $ contentTypeId ) ; $ this -> contentTypeService -> deleteContentType ( $ contentType ) ; $ this -> notificationHandler -> success ( $ this -> translator -> trans ( /** @Desc("Content Type '%name%' deleted.") */ 'content_type.delete.success' , [ '%name%' => $ contentType -> getName ( ) ] , 'content_type' ) ) ; } } ) ; if ( $ result instanceof Response ) { return $ result ; } } return $ this -> redirect ( $ this -> generateUrl ( 'ezplatform.content_type_group.view' , [ 'contentTypeGroupId' => $ group -> id ] ) ) ; }
Handles removing content types based on submitted form.

@param \Symfony\Component\HttpFoundation\Request $request
@param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup $group

@return \Symfony\Component\HttpFoundation\Response

@throws TranslationInvalidArgumentException
@throws InvalidOptionsException
@throws \InvalidArgumentException
Handles removing content types based on submitted form .