1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Box\Spout\Writer\ODS\Creator; |
4
|
|
|
|
5
|
|
|
use Box\Spout\Common\Manager\OptionsManagerInterface; |
6
|
|
|
use Box\Spout\Writer\Common\Creator\EntityFactory; |
7
|
|
|
use Box\Spout\Writer\Common\Entity\Options; |
8
|
|
|
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface; |
9
|
|
|
use Box\Spout\Writer\Common\Manager\SheetManager; |
10
|
|
|
use Box\Spout\Writer\ODS\Manager\Style\StyleManager; |
11
|
|
|
use Box\Spout\Writer\ODS\Manager\Style\StyleRegistry; |
12
|
|
|
use Box\Spout\Writer\ODS\Manager\WorkbookManager; |
13
|
|
|
use Box\Spout\Writer\ODS\Manager\WorksheetManager; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class ManagerFactory |
17
|
|
|
* Factory for managers needed by the ODS Writer |
18
|
|
|
* |
19
|
|
|
* @package Box\Spout\Writer\ODS\Creator |
20
|
|
|
*/ |
21
|
|
|
class ManagerFactory implements ManagerFactoryInterface |
22
|
|
|
{ |
23
|
|
|
/** @var EntityFactory */ |
24
|
|
|
protected $entityFactory; |
25
|
|
|
|
26
|
|
|
/** @var HelperFactory $helperFactory */ |
27
|
|
|
protected $helperFactory; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param EntityFactory $entityFactory |
31
|
|
|
* @param HelperFactory $helperFactory |
32
|
|
|
*/ |
33
|
48 |
|
public function __construct(EntityFactory $entityFactory, HelperFactory $helperFactory) |
34
|
|
|
{ |
35
|
48 |
|
$this->entityFactory = $entityFactory; |
36
|
48 |
|
$this->helperFactory = $helperFactory; |
37
|
48 |
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param OptionsManagerInterface $optionsManager |
41
|
|
|
* @return WorkbookManager |
42
|
|
|
*/ |
43
|
43 |
|
public function createWorkbookManager(OptionsManagerInterface $optionsManager) |
44
|
|
|
{ |
45
|
43 |
|
$workbook = $this->entityFactory->createWorkbook(); |
46
|
|
|
|
47
|
43 |
|
$fileSystemHelper = $this->helperFactory->createSpecificFileSystemHelper($optionsManager, $this->entityFactory); |
48
|
43 |
|
$fileSystemHelper->createBaseFilesAndFolders(); |
49
|
|
|
|
50
|
43 |
|
$styleManager = $this->createStyleManager($optionsManager); |
51
|
43 |
|
$worksheetManager = $this->createWorksheetManager(); |
52
|
|
|
|
53
|
43 |
|
return new WorkbookManager( |
54
|
43 |
|
$workbook, |
55
|
43 |
|
$optionsManager, |
56
|
43 |
|
$worksheetManager, |
57
|
43 |
|
$styleManager, |
58
|
43 |
|
$fileSystemHelper, |
59
|
43 |
|
$this->entityFactory, |
60
|
43 |
|
$this |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return WorksheetManager |
66
|
|
|
*/ |
67
|
43 |
|
private function createWorksheetManager() |
68
|
|
|
{ |
69
|
43 |
|
$stringsEscaper = $this->helperFactory->createStringsEscaper(); |
70
|
43 |
|
$stringsHelper = $this->helperFactory->createStringHelper(); |
71
|
|
|
|
72
|
43 |
|
return new WorksheetManager($stringsEscaper, $stringsHelper, $this->entityFactory); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return SheetManager |
77
|
|
|
*/ |
78
|
43 |
|
public function createSheetManager() |
79
|
|
|
{ |
80
|
43 |
|
$stringHelper = $this->helperFactory->createStringHelper(); |
81
|
43 |
|
return new SheetManager($stringHelper); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param OptionsManagerInterface $optionsManager |
86
|
|
|
* @return StyleManager |
87
|
|
|
*/ |
88
|
43 |
|
private function createStyleManager(OptionsManagerInterface $optionsManager) |
89
|
|
|
{ |
90
|
43 |
|
$styleRegistry = $this->createStyleRegistry($optionsManager); |
91
|
43 |
|
return new StyleManager($styleRegistry); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param OptionsManagerInterface $optionsManager |
96
|
|
|
* @return StyleRegistry |
97
|
|
|
*/ |
98
|
43 |
|
private function createStyleRegistry(OptionsManagerInterface $optionsManager) |
99
|
|
|
{ |
100
|
43 |
|
$defaultRowStyle = $optionsManager->getOption(Options::DEFAULT_ROW_STYLE); |
101
|
43 |
|
return new StyleRegistry($defaultRowStyle); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|