Skip to content

Commit

Permalink
Temporary workaround until the L6 upgrade can be merged in to use lea…
Browse files Browse the repository at this point in the history
…gue/csv >= 9.1
  • Loading branch information
Luke Towers committed Mar 31, 2020
1 parent 2fa306b commit 802d8c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/backend/behaviors/ImportExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Database\Eloquent\MassAssignmentException;
use League\Csv\Reader as CsvReader;
use League\Csv\Writer as CsvWriter;
use October\Rain\Parse\League\EscapeFormula as CsvEscapeFormula;
use ApplicationException;
use SplTempFileObject;
use Exception;
Expand Down Expand Up @@ -624,6 +625,9 @@ public function exportFromList($definition = null, $options = [])
$csv->setEnclosure($options['enclosure']);
$csv->setEscape($options['escape']);

// Temporary until upgrading to league/csv >= 9.1.0 (will be $csv->addFormatter($formatter))
$formatter = new CsvEscapeFormula();

/*
* Add headers
*/
Expand Down Expand Up @@ -657,6 +661,10 @@ public function exportFromList($definition = null, $options = [])
}
$record[] = $value;
}

// Temporary until upgrading to league/csv >= 9.1.0
$record = $formatter($record);

$csv->insertOne($record);
}

Expand Down
8 changes: 8 additions & 0 deletions modules/backend/models/ExportModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Model;
use Response;
use League\Csv\Writer as CsvWriter;
use October\Rain\Parse\League\EscapeFormula as CsvEscapeFormula;
use ApplicationException;
use SplTempFileObject;

Expand Down Expand Up @@ -111,6 +112,9 @@ protected function processExportData($columns, $results, $options)
$csv->setEscape($options['escape']);
}

// Temporary until upgrading to league/csv >= 9.1.0 (will be $csv->addFormatter($formatter))
$formatter = new CsvEscapeFormula();

/*
* Add headers
*/
Expand All @@ -124,6 +128,10 @@ protected function processExportData($columns, $results, $options)
*/
foreach ($results as $result) {
$data = $this->matchDataToColumns($result, $columns);

// Temporary until upgrading to league/csv >= 9.1.0
$data = $formatter($data);

$csv->insertOne($data);
}

Expand Down

0 comments on commit 802d8c8

Please sign in to comment.