Refactor readers for better di (#457)
* Refactor readers to get a proper DI Similar to what was done with writers, readers also needed to be updated to match the new way of doing things. This commits promotes a better DI (factories, injection through constructors). * Escapers should not be singletons Instead, they should be proper object that can be injected where needed.
This commit is contained in:
1 parent
4d6437fa77
commit
b7e46740ce
66 files changed
+1095
-618
No files matched your search
@@ -3,7 +3,8 @@
|
||||
namespace Box\Spout\Reader\ODS;
|
||||
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Reader\AbstractReader;
|
||||
use Box\Spout\Reader\ODS\Creator\EntityFactory;
|
||||
use Box\Spout\Reader\ReaderAbstract;
|
||||
|
||||
/**
|
||||
* Class Reader
|
||||
@@ -11,7 +12,7 @@ use Box\Spout\Reader\AbstractReader;
|
||||
*
|
||||
* @package Box\Spout\Reader\ODS
|
||||
*/
|
||||
class Reader extends AbstractReader
|
||||
class Reader extends ReaderAbstract
|
||||
{
|
||||
/** @var \ZipArchive */
|
||||
protected $zip;
|
||||
@@ -19,19 +20,6 @@ class Reader extends AbstractReader
|
||||
/** @var SheetIterator To iterator over the ODS sheets */
|
||||
protected $sheetIterator;
|
||||
|
||||
/**
|
||||
* Returns the reader's current options
|
||||
*
|
||||
* @return ReaderOptions
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
if (!isset($this->options)) {
|
||||
$this->options = new ReaderOptions();
|
||||
}
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether stream wrappers are supported
|
||||
*
|
||||
@@ -52,10 +40,15 @@ class Reader extends AbstractReader
|
||||
*/
|
||||
protected function openReader($filePath)
|
||||
{
|
||||
$this->zip = new \ZipArchive();
|
||||
/** @var EntityFactory $entityFactory */
|
||||
$entityFactory = $this->entityFactory;
|
||||
|
||||
$this->zip = $entityFactory->createZipArchive();
|
||||
|
||||
if ($this->zip->open($filePath) === true) {
|
||||
$this->sheetIterator = new SheetIterator($filePath, $this->getOptions());
|
||||
/** @var EntityFactory $entityFactory */
|
||||
$entityFactory = $this->entityFactory;
|
||||
$this->sheetIterator = $entityFactory->createSheetIterator($filePath, $this->optionsManager);
|
||||
} else {
|
||||
throw new IOException("Could not open $filePath for reading.");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user