src/Controller/MelisCoreGdprController.php
public function melisCoreGdprExtractSelectedAction()
    {
        $idsToBeExtracted = $this->getRequest()->getPost('id');

        /** @var \MelisCore\Service\MelisCoreGdprService $melisCoreGdprService */
        $melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService');
        $xml = $melisCoreGdprService->extractSelected($idsToBeExtracted);

        $name = "melisplatformgdpr.xml";
        //$response = $this->downloadXml($name, $xml);

        $response = $this->getResponse();

        $headers  = $response->getHeaders();
        $headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8');
        $headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$name."\"");
        $headers->addHeaderLine('Accept-Ranges', 'bytes');
        $headers->addHeaderLine('Content-Length', strlen($xml));
        $headers->addHeaderLine('fileName', $name);
        $response->setContent($xml);
        $response->setStatusCode(200);

        $view = new ViewModel();
        $view->setTerminal(true);
        $view->content = $response->getContent();

        return $view;
    }
public function melisCoreGdprExtractSelectedAction()
    {
        $idsToBeExtracted = $this->getRequest()->getPost('id');

        /** @var \MelisCore\Service\MelisCoreGdprService $melisCoreGdprService */
        $melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService');
        $xml = $melisCoreGdprService->extractSelected($idsToBeExtracted);

        $name = "melisplatformgdpr.xml";
        //$response = $this->downloadXml($name, $xml);

        $response = $this->getResponse();

        $headers  = $response->getHeaders();
        $headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8');
        $headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$name."\"");
        $headers->addHeaderLine('Accept-Ranges', 'bytes');
        $headers->addHeaderLine('Content-Length', strlen($xml));
        $headers->addHeaderLine('fileName', $name);
        $response->setContent($xml);
        $response->setStatusCode(200);

        $view = new ViewModel();
        $view->setTerminal(true);
        $view->content = $response->getContent();

        return $view;
    }
public function melisCoreGdprExtractSelectedAction ( ) { $ idsToBeExtracted = $ this -> getRequest ( ) -> getPost ( 'id' ) ; /** @var \MelisCore\Service\MelisCoreGdprService $melisCoreGdprService */ $ melisCoreGdprService = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreGdprService' ) ; $ xml = $ melisCoreGdprService -> extractSelected ( $ idsToBeExtracted ) ; $ name = "melisplatformgdpr.xml" ; //$response = $this->downloadXml($name, $xml); $ response = $ this -> getResponse ( ) ; $ headers = $ response -> getHeaders ( ) ; $ headers -> addHeaderLine ( 'Content-Type' , 'text/xml; charset=utf-8' ) ; $ headers -> addHeaderLine ( 'Content-Disposition' , "attachment; filename=\"" . $ name . "\"" ) ; $ headers -> addHeaderLine ( 'Accept-Ranges' , 'bytes' ) ; $ headers -> addHeaderLine ( 'Content-Length' , strlen ( $ xml ) ) ; $ headers -> addHeaderLine ( 'fileName' , $ name ) ; $ response -> setContent ( $ xml ) ; $ response -> setStatusCode ( 200 ) ; $ view = new ViewModel ( ) ; $ view -> setTerminal ( true ) ; $ view -> content = $ response -> getContent ( ) ; return $ view ; }
This will generate an xml file from the data based on the ids
@return HttpResponse
This will generate an xml file from the data based on the ids