1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Box\Spout\Reader\XLSX\Creator; |
4
|
|
|
|
5
|
|
|
use Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory; |
6
|
|
|
use Box\Spout\Reader\XLSX\Manager\SharedStringsManager; |
7
|
|
|
use Box\Spout\Reader\XLSX\Manager\SheetManager; |
8
|
|
|
use Box\Spout\Reader\XLSX\Manager\StyleManager; |
9
|
|
|
use Box\Spout\Reader\XLSX\Manager\WorkbookRelationshipsManager; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class ManagerFactory |
13
|
|
|
* Factory to create managers |
14
|
|
|
*/ |
15
|
|
|
class ManagerFactory |
16
|
|
|
{ |
17
|
|
|
/** @var HelperFactory */ |
18
|
|
|
private $helperFactory; |
19
|
|
|
|
20
|
|
|
/** @var CachingStrategyFactory */ |
21
|
|
|
private $cachingStrategyFactory; |
22
|
|
|
|
23
|
|
|
/** @var WorkbookRelationshipsManager */ |
24
|
|
|
private $cachedWorkbookRelationshipsManager; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param HelperFactory $helperFactory Factory to create helpers |
28
|
|
|
* @param CachingStrategyFactory $cachingStrategyFactory Factory to create shared strings caching strategies |
29
|
|
|
*/ |
30
|
50 |
|
public function __construct(HelperFactory $helperFactory, CachingStrategyFactory $cachingStrategyFactory) |
31
|
|
|
{ |
32
|
50 |
|
$this->helperFactory = $helperFactory; |
33
|
50 |
|
$this->cachingStrategyFactory = $cachingStrategyFactory; |
34
|
50 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param string $filePath Path of the XLSX file being read |
38
|
|
|
* @param string $tempFolder Temporary folder where the temporary files to store shared strings will be stored |
39
|
|
|
* @param EntityFactory $entityFactory Factory to create entities |
40
|
|
|
* @return SharedStringsManager |
41
|
|
|
*/ |
42
|
40 |
|
public function createSharedStringsManager($filePath, $tempFolder, $entityFactory) |
43
|
|
|
{ |
44
|
40 |
|
$workbookRelationshipsManager = $this->createWorkbookRelationshipsManager($filePath, $entityFactory); |
45
|
|
|
|
46
|
40 |
|
return new SharedStringsManager( |
47
|
40 |
|
$filePath, |
48
|
40 |
|
$tempFolder, |
49
|
40 |
|
$workbookRelationshipsManager, |
50
|
40 |
|
$entityFactory, |
51
|
40 |
|
$this->helperFactory, |
52
|
40 |
|
$this->cachingStrategyFactory |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $filePath Path of the XLSX file being read |
58
|
|
|
* @param EntityFactory $entityFactory Factory to create entities |
59
|
|
|
* @return WorkbookRelationshipsManager |
60
|
|
|
*/ |
61
|
40 |
|
private function createWorkbookRelationshipsManager($filePath, $entityFactory) |
62
|
|
|
{ |
63
|
40 |
|
if (!isset($this->cachedWorkbookRelationshipsManager)) { |
64
|
40 |
|
$this->cachedWorkbookRelationshipsManager = new WorkbookRelationshipsManager($filePath, $entityFactory); |
65
|
|
|
} |
66
|
|
|
|
67
|
40 |
|
return $this->cachedWorkbookRelationshipsManager; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param string $filePath Path of the XLSX file being read |
72
|
|
|
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager |
73
|
|
|
* @param \Box\Spout\Reader\XLSX\Manager\SharedStringsManager $sharedStringsManager Manages shared strings |
74
|
|
|
* @param EntityFactory $entityFactory Factory to create entities |
75
|
|
|
* @return SheetManager |
76
|
|
|
*/ |
77
|
39 |
|
public function createSheetManager($filePath, $optionsManager, $sharedStringsManager, $entityFactory) |
78
|
|
|
{ |
79
|
39 |
|
$escaper = $this->helperFactory->createStringsEscaper(); |
80
|
|
|
|
81
|
39 |
|
return new SheetManager($filePath, $optionsManager, $sharedStringsManager, $escaper, $entityFactory); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $filePath Path of the XLSX file being read |
86
|
|
|
* @param EntityFactory $entityFactory Factory to create entities |
87
|
|
|
* @return StyleManager |
88
|
|
|
*/ |
89
|
38 |
|
public function createStyleManager($filePath, $entityFactory) |
90
|
|
|
{ |
91
|
38 |
|
$workbookRelationshipsManager = $this->createWorkbookRelationshipsManager($filePath, $entityFactory); |
92
|
|
|
|
93
|
38 |
|
return new StyleManager($filePath, $workbookRelationshipsManager, $entityFactory); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|