You are here

protected function GdprTasksSarWorker::writeCsv in General Data Protection Regulation 7

Write data to a CSV file.

Parameters

string $filename: The filename to write to (supports streams).

array $content: The data to write, an array containing each row as an array.

2 calls to GdprTasksSarWorker::writeCsv()
GdprTasksSarWorker::build in modules/gdpr_tasks/src/Plugin/QueueWorker/GdprTasksSarWorker.php
Build the export files.
GdprTasksSarWorker::compile in modules/gdpr_tasks/src/Plugin/QueueWorker/GdprTasksSarWorker.php
Compile the SAR into a downloadable zip.

File

modules/gdpr_tasks/src/Plugin/QueueWorker/GdprTasksSarWorker.php, line 247

Class

GdprTasksSarWorker
Queue worker callback for processing SARs requests.

Code

protected function writeCsv($filename, array $content) {
  $handler = fopen($filename, 'w');

  // Write the UTF-8 BOM header so excel handles the encoding.
  fprintf($handler, chr(0xef) . chr(0xbb) . chr(0xbf));
  foreach ($content as $row) {
    fputcsv($handler, $row);
  }
  fclose($handler);
}