Introduce an options manager for all writers (#423)
This will improve the management of options and simplify some methods' signatures. This commit will also help moving the code to a better state regarding Dependency Injection.
This commit is contained in:
1 parent
f9d8ad8be3
commit
a366d0d0af
22 files changed
+447
-113
No files matched your search
@@ -4,6 +4,7 @@ namespace Box\Spout\Writer\ODS;
|
||||
|
||||
use Box\Spout\Writer\AbstractMultiSheetsWriter;
|
||||
use Box\Spout\Writer\Common;
|
||||
use Box\Spout\Writer\Common\Options;
|
||||
use Box\Spout\Writer\ODS\Internal\Workbook;
|
||||
|
||||
/**
|
||||
@@ -17,9 +18,6 @@ class Writer extends AbstractMultiSheetsWriter
|
||||
/** @var string Content-Type value for the header */
|
||||
protected static $headerContentType = 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
|
||||
/** @var string Temporary folder where the files to create the ODS will be stored */
|
||||
protected $tempFolder;
|
||||
|
||||
/** @var Internal\Workbook The workbook for the ODS file */
|
||||
protected $book;
|
||||
|
||||
@@ -36,7 +34,7 @@ class Writer extends AbstractMultiSheetsWriter
|
||||
{
|
||||
$this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.');
|
||||
|
||||
$this->tempFolder = $tempFolder;
|
||||
$this->optionsManager->setOption(Options::TEMP_FOLDER, $tempFolder);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -48,8 +46,7 @@ class Writer extends AbstractMultiSheetsWriter
|
||||
*/
|
||||
protected function openWriter()
|
||||
{
|
||||
$tempFolder = ($this->tempFolder) ? : sys_get_temp_dir();
|
||||
$this->book = new Workbook($tempFolder, $this->shouldCreateNewSheetsAutomatically, $this->defaultRowStyle);
|
||||
$this->book = new Workbook($this->optionsManager);
|
||||
$this->book->addNewSheetAndMakeItCurrent();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user