|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Box\Spout\Reader\XLSX\Creator; |
|
4
|
|
|
|
|
5
|
|
|
use Box\Spout\Common\Helper\Escaper; |
|
6
|
|
|
use Box\Spout\Reader\XLSX\Helper\CellValueFormatter; |
|
7
|
|
|
use Box\Spout\Reader\XLSX\Helper\SharedStringsCaching\CachingStrategyFactory; |
|
8
|
|
|
use Box\Spout\Reader\XLSX\Helper\SharedStringsHelper; |
|
9
|
|
|
use Box\Spout\Reader\XLSX\Helper\SheetHelper; |
|
10
|
|
|
use Box\Spout\Reader\XLSX\Helper\StyleHelper; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class EntityFactory |
|
15
|
|
|
* Factory to create helpers |
|
16
|
|
|
* |
|
17
|
|
|
* @package Box\Spout\Reader\XLSX\Creator |
|
18
|
|
|
*/ |
|
19
|
|
|
class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var CachingStrategyFactory */ |
|
22
|
|
|
private $cachingStrategyFactory; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param CachingStrategyFactory $cachingStrategyFactory Factory to create shared strings caching strategies |
|
26
|
|
|
*/ |
|
27
|
85 |
|
public function __construct(CachingStrategyFactory $cachingStrategyFactory) |
|
28
|
|
|
{ |
|
29
|
85 |
|
$this->cachingStrategyFactory = $cachingStrategyFactory; |
|
30
|
85 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param string $filePath Path of the XLSX file being read |
|
34
|
|
|
* @param string $tempFolder Temporary folder where the temporary files to store shared strings will be stored |
|
35
|
|
|
* @param EntityFactory $entityFactory Factory to create entities |
|
36
|
|
|
* @return SharedStringsHelper |
|
37
|
|
|
*/ |
|
38
|
35 |
|
public function createSharedStringsHelper($filePath, $tempFolder, $entityFactory) |
|
39
|
|
|
{ |
|
40
|
35 |
|
return new SharedStringsHelper($filePath, $tempFolder, $entityFactory, $this, $this->cachingStrategyFactory); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param string $filePath Path of the XLSX file being read |
|
45
|
|
|
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager |
|
46
|
|
|
* @param \Box\Spout\Reader\XLSX\Helper\SharedStringsHelper Helper to work with shared strings |
|
47
|
|
|
* @param \Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper |
|
48
|
|
|
* @param EntityFactory $entityFactory Factory to create entities |
|
49
|
|
|
* @return SheetHelper |
|
50
|
|
|
*/ |
|
51
|
34 |
|
public function createSheetHelper($filePath, $optionsManager, $sharedStringsHelper, $globalFunctionsHelper, $entityFactory) |
|
52
|
|
|
{ |
|
53
|
34 |
|
$escaper = $this->createStringsEscaper(); |
|
54
|
34 |
|
return new SheetHelper($filePath, $optionsManager, $sharedStringsHelper, $globalFunctionsHelper, $escaper, $entityFactory); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param string $filePath Path of the XLSX file being read |
|
59
|
|
|
* @param EntityFactory $entityFactory Factory to create entities |
|
60
|
|
|
* @return StyleHelper |
|
61
|
|
|
*/ |
|
62
|
33 |
|
public function createStyleHelper($filePath, $entityFactory) |
|
63
|
|
|
{ |
|
64
|
33 |
|
return new StyleHelper($filePath, $entityFactory); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param SharedStringsHelper $sharedStringsHelper Helper to work with shared strings |
|
69
|
|
|
* @param StyleHelper $styleHelper Helper to work with styles |
|
70
|
|
|
* @param bool $shouldFormatDates Whether date/time values should be returned as PHP objects or be formatted as strings |
|
71
|
|
|
* @return CellValueFormatter |
|
72
|
|
|
*/ |
|
73
|
33 |
|
public function createCellValueFormatter($sharedStringsHelper, $styleHelper, $shouldFormatDates) |
|
74
|
|
|
{ |
|
75
|
33 |
|
$escaper = $this->createStringsEscaper(); |
|
76
|
33 |
|
return new CellValueFormatter($sharedStringsHelper, $styleHelper, $shouldFormatDates, $escaper); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return Escaper\XLSX |
|
81
|
|
|
*/ |
|
82
|
34 |
|
public function createStringsEscaper() |
|
83
|
|
|
{ |
|
84
|
|
|
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */ |
|
85
|
34 |
|
return new Escaper\XLSX(); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|