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