Split Writer EntityFactory into interal and external ones
This commit is contained in:
parent
ca5962271e
commit
2d2151ac8d
@ -4,49 +4,16 @@ namespace Box\Spout\Writer\Common\Creator;
|
||||
|
||||
use Box\Spout\Writer\Common\Entity\Cell;
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||
use Box\Spout\Writer\Common\Entity\Workbook;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
use Box\Spout\Writer\Common\Manager\RowManager;
|
||||
use Box\Spout\Writer\Common\Manager\SheetManager;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||
|
||||
/**
|
||||
* Class EntityFactory
|
||||
* Factory to create entities
|
||||
* Factory to create external entities
|
||||
*/
|
||||
class EntityFactory
|
||||
{
|
||||
/**
|
||||
* @return Workbook
|
||||
*/
|
||||
public function createWorkbook()
|
||||
{
|
||||
return new Workbook();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $worksheetFilePath
|
||||
* @param Sheet $externalSheet
|
||||
* @return Worksheet
|
||||
*/
|
||||
public function createWorksheet($worksheetFilePath, Sheet $externalSheet)
|
||||
{
|
||||
return new Worksheet($worksheetFilePath, $externalSheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based)
|
||||
* @param string $associatedWorkbookId ID of the sheet's associated workbook
|
||||
* @param SheetManager $sheetManager To manage sheets
|
||||
* @return Sheet
|
||||
*/
|
||||
public function createSheet($sheetIndex, $associatedWorkbookId, $sheetManager)
|
||||
{
|
||||
return new Sheet($sheetIndex, $associatedWorkbookId, $sheetManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $cellValue
|
||||
* @param Style|null $cellStyle
|
||||
@ -57,14 +24,6 @@ class EntityFactory
|
||||
return new Cell($cellValue, $cellStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ZipArchive
|
||||
*/
|
||||
public function createZipArchive()
|
||||
{
|
||||
return new \ZipArchive();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $cells
|
||||
* @param Style|null $rowStyle
|
||||
|
52
src/Spout/Writer/Common/Creator/InternalEntityFactory.php
Normal file
52
src/Spout/Writer/Common/Creator/InternalEntityFactory.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Writer\Common\Creator;
|
||||
|
||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||
use Box\Spout\Writer\Common\Entity\Workbook;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
use Box\Spout\Writer\Common\Manager\SheetManager;
|
||||
|
||||
/**
|
||||
* Class InternalEntityFactory
|
||||
* Factory to create internal entities
|
||||
*/
|
||||
class InternalEntityFactory
|
||||
{
|
||||
/**
|
||||
* @return Workbook
|
||||
*/
|
||||
public function createWorkbook()
|
||||
{
|
||||
return new Workbook();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $worksheetFilePath
|
||||
* @param Sheet $externalSheet
|
||||
* @return Worksheet
|
||||
*/
|
||||
public function createWorksheet($worksheetFilePath, Sheet $externalSheet)
|
||||
{
|
||||
return new Worksheet($worksheetFilePath, $externalSheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based)
|
||||
* @param string $associatedWorkbookId ID of the sheet's associated workbook
|
||||
* @param SheetManager $sheetManager To manage sheets
|
||||
* @return Sheet
|
||||
*/
|
||||
public function createSheet($sheetIndex, $associatedWorkbookId, $sheetManager)
|
||||
{
|
||||
return new Sheet($sheetIndex, $associatedWorkbookId, $sheetManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ZipArchive
|
||||
*/
|
||||
public function createZipArchive()
|
||||
{
|
||||
return new \ZipArchive();
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Box\Spout\Writer\Common\Helper;
|
||||
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
|
||||
/**
|
||||
* Class ZipHelper
|
||||
@ -16,11 +16,11 @@ class ZipHelper
|
||||
const EXISTING_FILES_SKIP = 'skip';
|
||||
const EXISTING_FILES_OVERWRITE = 'overwrite';
|
||||
|
||||
/** @var EntityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory Factory to create entities */
|
||||
private $entityFactory;
|
||||
|
||||
/**
|
||||
* @param EntityFactory $entityFactory Factory to create entities
|
||||
* @param InternalEntityFactory $entityFactory Factory to create entities
|
||||
*/
|
||||
public function __construct($entityFactory)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace Box\Spout\Writer\Common\Manager;
|
||||
|
||||
use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
@ -37,7 +37,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
/** @var FileSystemWithRootFolderHelperInterface Helper to perform file system operations */
|
||||
protected $fileSystemHelper;
|
||||
|
||||
/** @var EntityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory Factory to create entities */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var ManagerFactoryInterface $managerFactory Factory to create managers */
|
||||
@ -52,7 +52,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
* @param WorksheetManagerInterface $worksheetManager
|
||||
* @param StyleManagerInterface $styleManager
|
||||
* @param FileSystemWithRootFolderHelperInterface $fileSystemHelper
|
||||
* @param EntityFactory $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @param ManagerFactoryInterface $managerFactory
|
||||
*/
|
||||
public function __construct(
|
||||
@ -61,7 +61,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
|
||||
WorksheetManagerInterface $worksheetManager,
|
||||
StyleManagerInterface $styleManager,
|
||||
FileSystemWithRootFolderHelperInterface $fileSystemHelper,
|
||||
EntityFactory $entityFactory,
|
||||
InternalEntityFactory $entityFactory,
|
||||
ManagerFactoryInterface $managerFactory
|
||||
) {
|
||||
$this->workbook = $workbook;
|
||||
|
@ -5,7 +5,7 @@ namespace Box\Spout\Writer\ODS\Creator;
|
||||
use Box\Spout\Common\Helper\Escaper;
|
||||
use Box\Spout\Common\Helper\StringHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Helper\ZipHelper;
|
||||
use Box\Spout\Writer\ODS\Helper\FileSystemHelper;
|
||||
@ -18,10 +18,10 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
|
||||
{
|
||||
/**
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
* @param EntityFactory $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @return FileSystemHelper
|
||||
*/
|
||||
public function createSpecificFileSystemHelper(OptionsManagerInterface $optionsManager, EntityFactory $entityFactory)
|
||||
public function createSpecificFileSystemHelper(OptionsManagerInterface $optionsManager, InternalEntityFactory $entityFactory)
|
||||
{
|
||||
$tempFolder = $optionsManager->getOption(Options::TEMP_FOLDER);
|
||||
$zipHelper = $this->createZipHelper($entityFactory);
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace Box\Spout\Writer\ODS\Creator;
|
||||
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Manager\SheetManager;
|
||||
@ -18,17 +18,17 @@ use Box\Spout\Writer\ODS\Manager\WorksheetManager;
|
||||
*/
|
||||
class ManagerFactory implements ManagerFactoryInterface
|
||||
{
|
||||
/** @var EntityFactory */
|
||||
/** @var InternalEntityFactory */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var HelperFactory $helperFactory */
|
||||
protected $helperFactory;
|
||||
|
||||
/**
|
||||
* @param EntityFactory $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @param HelperFactory $helperFactory
|
||||
*/
|
||||
public function __construct(EntityFactory $entityFactory, HelperFactory $helperFactory)
|
||||
public function __construct(InternalEntityFactory $entityFactory, HelperFactory $helperFactory)
|
||||
{
|
||||
$this->entityFactory = $entityFactory;
|
||||
$this->helperFactory = $helperFactory;
|
||||
|
@ -6,7 +6,7 @@ use Box\Spout\Common\Creator\HelperFactory;
|
||||
use Box\Spout\Common\Exception\UnsupportedTypeException;
|
||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||
use Box\Spout\Common\Type;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||
|
||||
@ -60,7 +60,7 @@ class WriterFactory
|
||||
$globalFunctionsHelper = new GlobalFunctionsHelper();
|
||||
|
||||
$helperFactory = new XLSX\Creator\HelperFactory();
|
||||
$managerFactory = new XLSX\Creator\ManagerFactory(new EntityFactory(), $helperFactory);
|
||||
$managerFactory = new XLSX\Creator\ManagerFactory(new InternalEntityFactory(), $helperFactory);
|
||||
|
||||
return new XLSX\Writer($optionsManager, $styleMerger, $globalFunctionsHelper, $helperFactory, $managerFactory);
|
||||
}
|
||||
@ -76,7 +76,7 @@ class WriterFactory
|
||||
$globalFunctionsHelper = new GlobalFunctionsHelper();
|
||||
|
||||
$helperFactory = new ODS\Creator\HelperFactory();
|
||||
$managerFactory = new ODS\Creator\ManagerFactory(new EntityFactory(), $helperFactory);
|
||||
$managerFactory = new ODS\Creator\ManagerFactory(new InternalEntityFactory(), $helperFactory);
|
||||
|
||||
return new ODS\Writer($optionsManager, $styleMerger, $globalFunctionsHelper, $helperFactory, $managerFactory);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ namespace Box\Spout\Writer\XLSX\Creator;
|
||||
use Box\Spout\Common\Helper\Escaper;
|
||||
use Box\Spout\Common\Helper\StringHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Helper\ZipHelper;
|
||||
use Box\Spout\Writer\XLSX\Helper\FileSystemHelper;
|
||||
@ -18,10 +18,10 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
|
||||
{
|
||||
/**
|
||||
* @param OptionsManagerInterface $optionsManager
|
||||
* @param EntityFactory $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @return FileSystemHelper
|
||||
*/
|
||||
public function createSpecificFileSystemHelper(OptionsManagerInterface $optionsManager, EntityFactory $entityFactory)
|
||||
public function createSpecificFileSystemHelper(OptionsManagerInterface $optionsManager, InternalEntityFactory $entityFactory)
|
||||
{
|
||||
$tempFolder = $optionsManager->getOption(Options::TEMP_FOLDER);
|
||||
$zipHelper = $this->createZipHelper($entityFactory);
|
||||
@ -31,10 +31,10 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EntityFactory $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @return ZipHelper
|
||||
*/
|
||||
private function createZipHelper(EntityFactory $entityFactory)
|
||||
private function createZipHelper(InternalEntityFactory $entityFactory)
|
||||
{
|
||||
return new ZipHelper($entityFactory);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace Box\Spout\Writer\XLSX\Creator;
|
||||
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Manager\SheetManager;
|
||||
@ -19,17 +19,17 @@ use Box\Spout\Writer\XLSX\Manager\WorksheetManager;
|
||||
*/
|
||||
class ManagerFactory implements ManagerFactoryInterface
|
||||
{
|
||||
/** @var EntityFactory */
|
||||
/** @var InternalEntityFactory */
|
||||
protected $entityFactory;
|
||||
|
||||
/** @var HelperFactory $helperFactory */
|
||||
protected $helperFactory;
|
||||
|
||||
/**
|
||||
* @param EntityFactory $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @param HelperFactory $helperFactory
|
||||
*/
|
||||
public function __construct(EntityFactory $entityFactory, HelperFactory $helperFactory)
|
||||
public function __construct(InternalEntityFactory $entityFactory, HelperFactory $helperFactory)
|
||||
{
|
||||
$this->entityFactory = $entityFactory;
|
||||
$this->helperFactory = $helperFactory;
|
||||
|
@ -7,7 +7,7 @@ use Box\Spout\Common\Exception\IOException;
|
||||
use Box\Spout\Common\Helper\Escaper\XLSX as XLSXEscaper;
|
||||
use Box\Spout\Common\Helper\StringHelper;
|
||||
use Box\Spout\Common\Manager\OptionsManagerInterface;
|
||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Cell;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Entity\Row;
|
||||
@ -51,7 +51,7 @@ EOD;
|
||||
/** @var StringHelper String helper */
|
||||
private $stringHelper;
|
||||
|
||||
/** @var EntityFactory Factory to create entities */
|
||||
/** @var InternalEntityFactory Factory to create entities */
|
||||
private $entityFactory;
|
||||
|
||||
/**
|
||||
@ -62,7 +62,7 @@ EOD;
|
||||
* @param SharedStringsManager $sharedStringsManager
|
||||
* @param XLSXEscaper $stringsEscaper
|
||||
* @param StringHelper $stringHelper
|
||||
* @param EntityFactory $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
*/
|
||||
public function __construct(
|
||||
OptionsManagerInterface $optionsManager,
|
||||
@ -70,7 +70,7 @@ EOD;
|
||||
SharedStringsManager $sharedStringsManager,
|
||||
XLSXEscaper $stringsEscaper,
|
||||
StringHelper $stringHelper,
|
||||
EntityFactory $entityFactory
|
||||
InternalEntityFactory $entityFactory
|
||||
) {
|
||||
$this->shouldUseInlineStrings = $optionsManager->getOption(Options::SHOULD_USE_INLINE_STRINGS);
|
||||
$this->styleManager = $styleManager;
|
||||
|
Loading…
x
Reference in New Issue
Block a user