Split Writer EntityFactory into interal and external ones
This commit is contained in:
1 parent
ca5962271e
commit
2d2151ac8d
10 files changed
+83
-72
No files matched your search
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user