bundle/Controller/Admin/AdminController.php
public function handleCollectionAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ez:infocollector:read');

        $collectionId = $request->request->get('CollectionId');
        $contentId = $request->request->get('ContentId');
        $fields = $request->request->get('FieldId', []);
        $count = count($fields);

        if (
            ($request->request->has('AnonymizeFieldAction') || $request->request->has('DeleteFieldAction'))
            && empty($fields)
        ) {
            $this->addFlashMessage('errors', 'fields_not_selected');

            return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
        }

        if ($request->request->has('DeleteFieldAction')) {
            $query = new Query([
                'contentId' => $contentId,
                'collectionId' => $collectionId,
                'fields' => $fields,
            ]);
            $this->service->deleteCollectionFields($query);

            $this->addFlashMessage('success', 'field_removed', $count);

            return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
        }

        if ($request->request->has('AnonymizeFieldAction')) {
            $this->anonymizer->anonymizeCollection($collectionId, $fields);

            $this->addFlashMessage('success', 'field_anonymized', $count);

            return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
        }

        if ($request->request->has('DeleteCollectionAction')) {
            $query = new Query([
                'contentId' => $contentId,
                'collections' => [$collectionId],
            ]);
            $this->service->deleteCollections($query);

            $this->addFlashMessage("success", "collection_removed");

            return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]);

        }

        if ($request->request->has('AnonymizeCollectionAction')) {
            $this->anonymizer->anonymizeCollection($collectionId);

            $this->addFlashMessage("success", "collection_anonymized");

            return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
        }

        $this->addFlashMessage('error', 'something_went_wrong');

        return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
    }
public function handleCollectionAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ez:infocollector:read');

        $collectionId = $request->request->get('CollectionId');
        $contentId = $request->request->get('ContentId');
        $fields = $request->request->get('FieldId', []);
        $count = count($fields);

        if (
            ($request->request->has('AnonymizeFieldAction') || $request->request->has('DeleteFieldAction'))
            && empty($fields)
        ) {
            $this->addFlashMessage('errors', 'fields_not_selected');

            return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
        }

        if ($request->request->has('DeleteFieldAction')) {
            $query = new Query([
                'contentId' => $contentId,
                'collectionId' => $collectionId,
                'fields' => $fields,
            ]);
            $this->service->deleteCollectionFields($query);

            $this->addFlashMessage('success', 'field_removed', $count);

            return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
        }

        if ($request->request->has('AnonymizeFieldAction')) {
            $this->anonymizer->anonymizeCollection($collectionId, $fields);

            $this->addFlashMessage('success', 'field_anonymized', $count);

            return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
        }

        if ($request->request->has('DeleteCollectionAction')) {
            $query = new Query([
                'contentId' => $contentId,
                'collections' => [$collectionId],
            ]);
            $this->service->deleteCollections($query);

            $this->addFlashMessage("success", "collection_removed");

            return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]);

        }

        if ($request->request->has('AnonymizeCollectionAction')) {
            $this->anonymizer->anonymizeCollection($collectionId);

            $this->addFlashMessage("success", "collection_anonymized");

            return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
        }

        $this->addFlashMessage('error', 'something_went_wrong');

        return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
    }
public function handleCollectionAction ( Request $ request ) { $ this -> denyAccessUnlessGranted ( 'ez:infocollector:read' ) ; $ collectionId = $ request -> request -> get ( 'CollectionId' ) ; $ contentId = $ request -> request -> get ( 'ContentId' ) ; $ fields = $ request -> request -> get ( 'FieldId' , [ ] ) ; $ count = count ( $ fields ) ; if ( ( $ request -> request -> has ( 'AnonymizeFieldAction' ) || $ request -> request -> has ( 'DeleteFieldAction' ) ) && empty ( $ fields ) ) { $ this -> addFlashMessage ( 'errors' , 'fields_not_selected' ) ; return $ this -> redirectToRoute ( 'netgen_information_collection.route.admin.view' , [ 'collectionId' => $ collectionId ] ) ; } if ( $ request -> request -> has ( 'DeleteFieldAction' ) ) { $ query = new Query ( [ 'contentId' => $ contentId , 'collectionId' => $ collectionId , 'fields' => $ fields , ] ) ; $ this -> service -> deleteCollectionFields ( $ query ) ; $ this -> addFlashMessage ( 'success' , 'field_removed' , $ count ) ; return $ this -> redirectToRoute ( 'netgen_information_collection.route.admin.view' , [ 'collectionId' => $ collectionId ] ) ; } if ( $ request -> request -> has ( 'AnonymizeFieldAction' ) ) { $ this -> anonymizer -> anonymizeCollection ( $ collectionId , $ fields ) ; $ this -> addFlashMessage ( 'success' , 'field_anonymized' , $ count ) ; return $ this -> redirectToRoute ( 'netgen_information_collection.route.admin.view' , [ 'collectionId' => $ collectionId ] ) ; } if ( $ request -> request -> has ( 'DeleteCollectionAction' ) ) { $ query = new Query ( [ 'contentId' => $ contentId , 'collections' => [ $ collectionId ] , ] ) ; $ this -> service -> deleteCollections ( $ query ) ; $ this -> addFlashMessage ( "success" , "collection_removed" ) ; return $ this -> redirectToRoute ( 'netgen_information_collection.route.admin.collection_list' , [ 'contentId' => $ contentId ] ) ; } if ( $ request -> request -> has ( 'AnonymizeCollectionAction' ) ) { $ this -> anonymizer -> anonymizeCollection ( $ collectionId ) ; $ this -> addFlashMessage ( "success" , "collection_anonymized" ) ; return $ this -> redirectToRoute ( 'netgen_information_collection.route.admin.view' , [ 'collectionId' => $ collectionId ] ) ; } $ this -> addFlashMessage ( 'error' , 'something_went_wrong' ) ; return $ this -> redirectToRoute ( 'netgen_information_collection.route.admin.view' , [ 'collectionId' => $ collectionId ] ) ; }
Handles action on collection details page

@param \Symfony\Component\HttpFoundation\Request $request

@return \Symfony\Component\HttpFoundation\RedirectResponse
Handles action on collection details page