Move Sheet to Common/Entity (#438)

... and introduce a SheetManager
This commit is contained in:
Adrien Loison authored and GitHub committed 2017-05-30 16:49:07 +02:00
1 parent 30366e6a5d
commit 3bb4fd3d48
14 files changed
+252 -112

No files matched your search

@@ -2,7 +2,7 @@
namespace Box\Spout\Writer\Common\Creator;
use Box\Spout\Writer\Common\Sheet;
use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Workbook;
use Box\Spout\Writer\Common\Entity\Worksheet;
@@ -14,6 +14,19 @@ use Box\Spout\Writer\Common\Entity\Worksheet;
*/
class EntityFactory
{
/** @var ManagerFactory */
private $managerFactory;
/**
* EntityFactory constructor.
*
* @param ManagerFactory $managerFactory
*/
public function __construct(ManagerFactory $managerFactory)
{
$this->managerFactory = $managerFactory;
}
/**
* @return Workbook
*/
@@ -31,4 +44,15 @@ class EntityFactory
{
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
* @return Sheet
*/
public function createSheet($sheetIndex, $associatedWorkbookId)
{
$sheetManager = $this->managerFactory->createSheetManager();
return new Sheet($sheetIndex, $associatedWorkbookId, $sheetManager);
}
}