Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV files: added possibility to select PHP input file mode #14610

Merged
merged 3 commits into from
May 6, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/internal/Magento/Framework/File/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,17 @@ public function getDataPairs($file, $keyIndex = 0, $valueIndex = 1)
/**
* Saving data row array into file
*
* @param string $file
* @param array $data
* @return $this
* @param string $file
* @param array $data
* @param string $mode
*
* @return $this
*
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function saveData($file, $data)
public function saveData($file, $data, $mode = 'w')
Copy link
Contributor

@sidolov sidolov Apr 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add new method parameters according to our Backward Compatible Development Guide

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. But in my very humble opinion, it makes the code bloated. My first proposal was not breaking backward compatibility and kept the original code.

{
$fh = fopen($file, 'w');
$fh = fopen($file, $mode);
foreach ($data as $dataRow) {
$this->file->filePutCsv($fh, $dataRow, $this->_delimiter, $this->_enclosure);
}
Expand Down