public function deleteCollectionAction(Request $request)
    {
        if (null === $uids = $request->get('uids', null)) {
            throw new BadRequestHttpException('uid is missing.');
        }

        $result = [];
        $statusCode = 204;
        $pages = $this->getPageRepository()->findBy(['_uid' => $uids]);
        foreach ($pages as $page) {
            try {
                if ($page->isDeleted()) {
                    $this->hardDelete($page);
                } else {
                    $this->softDelete($page);
                }

                $result[] = [
                    'uid'        => $page->getUid(),
                    'statusCode' => 204,
                    'message'    => 'OK',
                ];
            } catch (AccessDeniedException $e) {
                $result[] = [
                    'uid'        => $page->getUid(),
                    'statusCode' => 401,
                    'message'    => $e->getMessage(),
                ];
                $statusCode = ($statusCode < 401) ? 401 : $statusCode;
            } catch (\Exception $e) {
                if ($e instanceof BadRequestHttpException || $e instanceof InsufficientAuthenticationException) {
                    $result[] = [
                        'uid'        => $page->getUid(),
                        'statusCode' => 403,
                        'message'    => $e->getMessage(),
                    ];
                    $statusCode = ($statusCode < 403) ? 403 : $statusCode;
                } else {
                    $result[] = [
                        'uid'        => $page->getUid(),
                        'statusCode' => 500,
                        'message'    => $e->getMessage(),
                    ];
                    $statusCode = ($statusCode < 500) ? 500 : $statusCode;
                }
            }
        }

        $this->getEntityManager()->flush();

        return $this->createJsonResponse($result, $statusCode);
    }
public function deleteCollectionAction(Request $request)
    {
        if (null === $uids = $request->get('uids', null)) {
            throw new BadRequestHttpException('uid is missing.');
        }

        $result = [];
        $statusCode = 204;
        $pages = $this->getPageRepository()->findBy(['_uid' => $uids]);
        foreach ($pages as $page) {
            try {
                if ($page->isDeleted()) {
                    $this->hardDelete($page);
                } else {
                    $this->softDelete($page);
                }

                $result[] = [
                    'uid'        => $page->getUid(),
                    'statusCode' => 204,
                    'message'    => 'OK',
                ];
            } catch (AccessDeniedException $e) {
                $result[] = [
                    'uid'        => $page->getUid(),
                    'statusCode' => 401,
                    'message'    => $e->getMessage(),
                ];
                $statusCode = ($statusCode < 401) ? 401 : $statusCode;
            } catch (\Exception $e) {
                if ($e instanceof BadRequestHttpException || $e instanceof InsufficientAuthenticationException) {
                    $result[] = [
                        'uid'        => $page->getUid(),
                        'statusCode' => 403,
                        'message'    => $e->getMessage(),
                    ];
                    $statusCode = ($statusCode < 403) ? 403 : $statusCode;
                } else {
                    $result[] = [
                        'uid'        => $page->getUid(),
                        'statusCode' => 500,
                        'message'    => $e->getMessage(),
                    ];
                    $statusCode = ($statusCode < 500) ? 500 : $statusCode;
                }
            }
        }

        $this->getEntityManager()->flush();

        return $this->createJsonResponse($result, $statusCode);
    }
public function deleteCollectionAction ( Request $ request ) { if ( null === $ uids = $ request -> get ( 'uids' , null ) ) { throw new BadRequestHttpException ( 'uid is missing.' ) ; } $ result = [ ] ; $ statusCode = 204 ; $ pages = $ this -> getPageRepository ( ) -> findBy ( [ '_uid' => $ uids ] ) ; foreach ( $ pages as $ page ) { try { if ( $ page -> isDeleted ( ) ) { $ this -> hardDelete ( $ page ) ; } else { $ this -> softDelete ( $ page ) ; } $ result [ ] = [ 'uid' => $ page -> getUid ( ) , 'statusCode' => 204 , 'message' => 'OK' , ] ; } catch ( AccessDeniedException $ e ) { $ result [ ] = [ 'uid' => $ page -> getUid ( ) , 'statusCode' => 401 , 'message' => $ e -> getMessage ( ) , ] ; $ statusCode = ( $ statusCode < 401 ) ? 401 : $ statusCode ; } catch ( \ Exception $ e ) { if ( $ e instanceof BadRequestHttpException || $ e instanceof InsufficientAuthenticationException ) { $ result [ ] = [ 'uid' => $ page -> getUid ( ) , 'statusCode' => 403 , 'message' => $ e -> getMessage ( ) , ] ; $ statusCode = ( $ statusCode < 403 ) ? 403 : $ statusCode ; } else { $ result [ ] = [ 'uid' => $ page -> getUid ( ) , 'statusCode' => 500 , 'message' => $ e -> getMessage ( ) , ] ; $ statusCode = ( $ statusCode < 500 ) ? 500 : $ statusCode ; } } } $ this -> getEntityManager ( ) -> flush ( ) ; return $ this -> createJsonResponse ( $ result , $ statusCode ) ; }
Delete page collecton.

@return \Symfony\Component\HttpFoundation\JsonResponse

@Rest\Security("is_fully_authenticated() & has_role('ROLE_API_USER')")
Delete page collecton .