Export CSV files with .csv extension

refs #2808

Signed-off-by: Eric Lippmann <eric.lippmann@icinga.com>
This commit is contained in:
Mikesch-mp 2017-10-05 18:00:08 +02:00 committed by Eric Lippmann
parent d11775a6b8
commit d76a18dd91
1 changed files with 7 additions and 1 deletions

View File

@ -45,7 +45,13 @@ class Controller extends IcingaWebController
}
if ($this->_getParam('format') === 'csv'
|| $this->_request->getHeader('Accept') === 'text/csv') {
Csv::fromQuery($query)->dump();
$response = $this->getResponse();
$response
->setHeader('Content-Type', 'text/csv')
->setHeader('Cache-Control', 'no-store')
->setHeader('Content-Disposition', 'attachment; filename=' . $this->getRequest()->getActionName() . '.csv')
->appendBody((string) Csv::fromQuery($query))
->sendResponse();
exit;
}
}