rudimentary export options

This commit is contained in:
2018-07-29 20:19:19 +02:00
parent 3bf9b68503
commit 1037f438ce
15 changed files with 522 additions and 103 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Tables;
class JsonExporter extends BaseExporter
{
/**
* @return string - mime type for the downloaded file
*/
protected function getMimeType()
{
return 'application/json';
}
/**
* @return string - file extension for the downloaded file
*/
protected function getFileExtension()
{
return 'json';
}
/**
* Write the document to stdout ('php://output')
*/
protected function writeDocument()
{
echo "[\n";
$first = true;
foreach ($this->iterateRows() as $row) {
if ($first) {
$first = false;
} else {
echo ",\n";
}
echo json_encode($row, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}
echo "\n]\n";
}
}