mirror of https://github.com/MISP/MISP
chg: [dashboard:exportcsv] Small refactoring
parent
0274f8b633
commit
51a1441a4a
|
@ -206,10 +206,11 @@ class DashboardsController extends AppController
|
|||
} else { // second element is an array
|
||||
$csv = array_map(function($row) {
|
||||
$flattened = array_values(Hash::flatten($row));
|
||||
$stringified = array_map('json_encode', $flattened);
|
||||
$stringified = array_map('strval', $flattened);
|
||||
return implode(',', $stringified);
|
||||
}, $toConvert);
|
||||
$csv = implode(',', array_keys($toConvert[0])) . PHP_EOL . implode(PHP_EOL, array_values($csv));
|
||||
$rowKey = implode(',', array_map('strval', array_keys(Hash::flatten($toConvert[0]))));
|
||||
$csv = $rowKey . PHP_EOL . implode(PHP_EOL, array_values($csv));
|
||||
}
|
||||
}
|
||||
return $this->RestResponse->viewData($csv, 'text/csv');
|
||||
|
|
Loading…
Reference in New Issue