added confirmation email for eshop

This commit is contained in:
2024-09-10 13:43:32 +02:00
parent 39c1604db4
commit 11e2b6f2e2
5 changed files with 137 additions and 17 deletions

View File

@@ -135,5 +135,26 @@ class Helper {
$controller->layout()->setTemplate("VueViews/Vue");
}
/**
* Converts an array of objects to a CSV file.
* @param array $rows The array of objects to convert to CSV.
* @return string The CSV file content.
*/
public static function arrayToCsv(array $rows): string {
$output = fopen('php://temp', 'w');
// Add headers
fputcsv($output, array_keys((array) $rows[0]));
// Add rows
foreach ($rows as $row) {
fputcsv($output, (array) $row);
}
rewind($output);
$csv = stream_get_contents($output);
fclose($output);
return $csv;
}
}