using mem handler

This commit is contained in:
Jacson Passold 2018-04-11 16:12:41 -03:00
parent 6356fb4705
commit 97b08364f9
1 changed files with 4 additions and 4 deletions

View File

@ -16,11 +16,11 @@ class Csv extends Type {
'Content-Type: text/csv; charset=' . get_option( 'blog_charset' ), 'Content-Type: text/csv; charset=' . get_option( 'blog_charset' ),
'Content-disposition: attachment;filename=tainacan.csv'] // TODO filter/optional 'Content-disposition: attachment;filename=tainacan.csv'] // TODO filter/optional
); );
ob_start();
$csv = fopen('php://output', 'w'); $csv = fopen('php://memory', 'w');
$this->array_to_csv($response->get_data(), apply_filters('tainacan-exposer-csv', $csv)); $this->array_to_csv($response->get_data(), apply_filters('tainacan-exposer-csv', $csv));
$ret_csv = ob_get_clean(); rewind($csv);
ob_end_clean(); $ret_csv = stream_get_contents($csv);
fclose($csv); fclose($csv);
$response->set_data($ret_csv); $response->set_data($ret_csv);
return $response; return $response;