improve script for downloading exports

This commit is contained in:
2018-06-12 17:58:02 +02:00
parent dd05fa0be7
commit 587b248549
6 changed files with 114 additions and 50 deletions

View File

@@ -412,9 +412,29 @@ class ExportController extends Controller
}
public function downloadResultAction(Request $request, $alias)
{
return $this->render("ChillMainBundle:Export:download.html.twig", [
{
/* @var $exportManager \Chill\MainBundle\Export\ExportManager */
$exportManager = $this->get('chill.main.export_manager');
$formCenters = $this->createCreateFormExport($alias, 'generate_centers');
$formCenters->handleRequest($request);
$dataCenters = $formCenters->getData();
$formExport = $this->createCreateFormExport($alias, 'generate_export', $dataCenters);
$formExport->handleRequest($request);
$dataExport = $formExport->getData();
dump($dataExport);
$formatterAlias = $exportManager->getFormatterAlias($dataExport['export']);
$formater = $exportManager->getFormatter($formatterAlias);
$viewVariables = [
'alias' => $alias
]);
];
if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) {
// due to a bug in php, we add the mime type in the download view
$viewVariables['mime_type'] = 'text/csv';
}
return $this->render("ChillMainBundle:Export:download.html.twig", $viewVariables);
}
}