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:
Adrien Loison authored and GitHub committed 2017-08-27 00:01:17 +02:00
1 parent 4d6437fa77
commit b7e46740ce
66 files changed
+1095 -618

No files matched your search

@@ -2,13 +2,13 @@
namespace Box\Spout\Writer\XLSX\Creator;
use Box\Spout\Common\Escaper;
use Box\Spout\Common\Helper\Escaper;
use Box\Spout\Common\Helper\StringHelper;
use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\InternalFactoryInterface;
use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Helper\ZipHelper;
use Box\Spout\Writer\Common\Manager\OptionsManagerInterface;
use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\XLSX\Helper\FileSystemHelper;
use Box\Spout\Writer\XLSX\Manager\SharedStringsManager;
use Box\Spout\Writer\XLSX\Manager\Style\StyleManager;
@@ -113,8 +113,9 @@ class InternalFactory implements InternalFactoryInterface
{
$tempFolder = $optionsManager->getOption(Options::TEMP_FOLDER);
$zipHelper = $this->createZipHelper();
$escaper = $this->createStringsEscaper();
return new FileSystemHelper($tempFolder, $zipHelper);
return new FileSystemHelper($tempFolder, $zipHelper, $escaper);
}
/**
@@ -130,7 +131,7 @@ class InternalFactory implements InternalFactoryInterface
*/
private function createStringsEscaper()
{
return Escaper\XLSX::getInstance();
return new Escaper\XLSX();
}
/**
@@ -140,4 +141,4 @@ class InternalFactory implements InternalFactoryInterface
{
return new StringHelper();
}
}
}