Skip to content

Commit 4acdf0a

Browse files
committed
Issue #9 Add options for temp file
1 parent 62c8f2f commit 4acdf0a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/ExcelFile.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ class ExcelFile extends Object
1515
*/
1616
public $writerClass = '\PHPExcel_Writer_Excel2007';
1717

18+
/**
19+
* @var array options to pass to the constructor of \mikehaertl\tmp\File,
20+
* indexed by option name. Available keys are 'suffix', 'prefix' and 'directory'.
21+
* This is only useful if creation of the temporary file fails for some reason.
22+
*/
23+
public $fileOptions = [];
24+
1825
protected $_writer;
1926
protected $_workbook;
2027
protected $_sheets;
@@ -50,7 +57,10 @@ public function getWorkbook()
5057
public function getTmpFile()
5158
{
5259
if ($this->_tmpFile===null) {
53-
$this->_tmpFile = new File('');
60+
$suffix = isset($this->fileOptions['suffix']) ? $this->fileOptions['suffix'] : null;
61+
$prefix = isset($this->fileOptions['prefix']) ? $this->fileOptions['prefix'] : null;
62+
$directory = isset($this->fileOptions['directory']) ? $this->fileOptions['directory'] : null;
63+
$this->_tmpFile = new File('', $suffix, $prefix, $directory);
5464
}
5565
return $this->_tmpFile;
5666
}

0 commit comments

Comments
 (0)