Random DI improvements (#458)

* Add random DI improvements

Fixing things that were previously missed

* Split InternalFactory into Manager and Helper factories
This commit is contained in:
Adrien Loison authored and GitHub committed 2017-08-27 01:44:20 +02:00
1 parent b7e46740ce
commit 4ec3a21170
19 files changed
+317 -183

No files matched your search

@@ -25,11 +25,12 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
}
/**
* @param EntityFactory $entityFactory
* @return SettingsHelper
*/
public function createSettingsHelper()
public function createSettingsHelper($entityFactory)
{
return new SettingsHelper();
return new SettingsHelper($entityFactory);
}
/**
+13 -1
View File
@@ -3,6 +3,7 @@
namespace Box\Spout\Reader\ODS\Helper;
use Box\Spout\Reader\Exception\XMLProcessingException;
use Box\Spout\Reader\ODS\Creator\EntityFactory;
use Box\Spout\Reader\Wrapper\XMLReader;
/**
@@ -20,13 +21,24 @@ class SettingsHelper
const XML_ATTRIBUTE_CONFIG_NAME = 'config:name';
const XML_ATTRIBUTE_VALUE_ACTIVE_TABLE = 'ActiveTable';
/** @var EntityFactory Factory to create entities */
private $entityFactory;
/**
* @param EntityFactory $entityFactory Factory to create entities
*/
public function __construct($entityFactory)
{
$this->entityFactory = $entityFactory;
}
/**
* @param string $filePath Path of the file to be read
* @return string|null Name of the sheet that was defined as active or NULL if none found
*/
public function getActiveSheetName($filePath)
{
$xmlReader = new XMLReader();
$xmlReader = $this->entityFactory->createXMLReader();
if ($xmlReader->openFileInZip($filePath, self::SETTINGS_XML_FILE_PATH) === false) {
return null;
}
+1 -1
View File
@@ -63,7 +63,7 @@ class SheetIterator implements IteratorInterface
$this->escaper = $helperFactory->createStringsEscaper();
$settingsHelper = $helperFactory->createSettingsHelper();
$settingsHelper = $helperFactory->createSettingsHelper($entityFactory);
$this->activeSheetName = $settingsHelper->getActiveSheetName($filePath);
}