1 | <?php |
||
27 | class Settings |
||
28 | { |
||
29 | /** constants */ |
||
30 | /** Available Zip library classes */ |
||
31 | const PCLZIP = \PhpOffice\PhpSpreadsheet\Shared\ZipArchive::class; |
||
32 | const ZIPARCHIVE = \ZipArchive::class; |
||
33 | |||
34 | /** Optional Chart Rendering libraries */ |
||
35 | const CHART_RENDERER_JPGRAPH = 'JpGraph'; |
||
36 | |||
37 | /** Optional PDF Rendering libraries */ |
||
38 | const PDF_RENDERER_TCPDF = 'TcPDF'; |
||
39 | const PDF_RENDERER_DOMPDF = 'DomPDF'; |
||
40 | const PDF_RENDERER_MPDF = 'MPDF'; |
||
41 | |||
42 | private static $chartRenderers = [ |
||
43 | self::CHART_RENDERER_JPGRAPH, |
||
44 | ]; |
||
45 | |||
46 | private static $pdfRenderers = [ |
||
47 | self::PDF_RENDERER_TCPDF, |
||
48 | self::PDF_RENDERER_DOMPDF, |
||
49 | self::PDF_RENDERER_MPDF, |
||
50 | ]; |
||
51 | |||
52 | /** |
||
53 | * Name of the class used for Zip file management |
||
54 | * e.g. |
||
55 | * ZipArchive. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | private static $zipClass = self::ZIPARCHIVE; |
||
60 | |||
61 | /** |
||
62 | * Name of the external Library used for rendering charts |
||
63 | * e.g. |
||
64 | * jpgraph. |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | private static $chartRendererName; |
||
69 | |||
70 | /** |
||
71 | * Directory Path to the external Library used for rendering charts. |
||
72 | * |
||
73 | * @var string |
||
74 | */ |
||
75 | private static $chartRendererPath; |
||
76 | |||
77 | /** |
||
78 | * Name of the external Library used for rendering PDF files |
||
79 | * e.g. |
||
80 | * mPDF. |
||
81 | * |
||
82 | * @var string |
||
83 | */ |
||
84 | private static $pdfRendererName; |
||
85 | |||
86 | /** |
||
87 | * Default options for libxml loader. |
||
88 | * |
||
89 | * @var int |
||
90 | */ |
||
91 | private static $libXmlLoaderOptions = null; |
||
92 | |||
93 | /** |
||
94 | * Set the Zip handler Class that PhpSpreadsheet should use for Zip file management (PCLZip or ZipArchive). |
||
95 | * |
||
96 | * @param string $zipClass The Zip handler class that PhpSpreadsheet should use for Zip file management |
||
97 | * e.g. \PhpOffice\PhpSpreadsheet\Settings::PCLZIP or \PhpOffice\PhpSpreadsheet\Settings::ZIPARCHIVE |
||
98 | * |
||
99 | * @return bool Success or failure |
||
100 | */ |
||
101 | 1 | public static function setZipClass($zipClass) |
|
112 | |||
113 | /** |
||
114 | * Return the name of the Zip handler Class that PhpSpreadsheet is configured to use (PCLZip or ZipArchive) |
||
115 | * or Zip file management. |
||
116 | * |
||
117 | * @return string Name of the Zip handler Class that PhpSpreadsheet is configured to use |
||
118 | * for Zip file management |
||
119 | * e.g. \PhpOffice\PhpSpreadsheet\Settings::PCLZIP or \PhpOffice\PhpSpreadsheet\Settings::ZIPARCHIVE |
||
120 | */ |
||
121 | 58 | public static function getZipClass() |
|
125 | |||
126 | /** |
||
127 | * Return the name of the method that is currently configured for cell cacheing. |
||
128 | * |
||
129 | * @return string Name of the cacheing method |
||
130 | */ |
||
131 | public static function getCacheStorageMethod() |
||
135 | |||
136 | /** |
||
137 | * Return the name of the class that is currently being used for cell cacheing. |
||
138 | * |
||
139 | * @return string Name of the class currently being used for cacheing |
||
140 | */ |
||
141 | public static function getCacheStorageClass() |
||
145 | |||
146 | /** |
||
147 | * Set the method that should be used for cell caching. |
||
148 | * |
||
149 | * @param string $method Name of the caching method |
||
150 | * @param array $arguments Optional configuration arguments for the caching method |
||
151 | * |
||
152 | * @return bool Success or failure |
||
153 | */ |
||
154 | public static function setCacheStorageMethod($method = CachedObjectStorageFactory::CACHE_IN_MEMORY, $arguments = []) |
||
158 | |||
159 | /** |
||
160 | * Set the locale code to use for formula translations and any special formatting. |
||
161 | * |
||
162 | * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk") |
||
163 | * |
||
164 | * @return bool Success or failure |
||
165 | */ |
||
166 | public static function setLocale($locale = 'en_us') |
||
170 | |||
171 | /** |
||
172 | * Set details of the external library that PhpSpreadsheet should use for rendering charts. |
||
173 | * |
||
174 | * @param string $libraryName Internal reference name of the library |
||
175 | * e.g. \PhpOffice\PhpSpreadsheet\Settings::CHART_RENDERER_JPGRAPH |
||
176 | * @param string $libraryBaseDir Directory path to the library's base folder |
||
177 | * |
||
178 | * @return bool Success or failure |
||
179 | */ |
||
180 | 3 | public static function setChartRenderer($libraryName, $libraryBaseDir) |
|
188 | |||
189 | /** |
||
190 | * Identify to PhpSpreadsheet the external library to use for rendering charts. |
||
191 | * |
||
192 | * @param string $libraryName Internal reference name of the library |
||
193 | * e.g. \PhpOffice\PhpSpreadsheet\Settings::CHART_RENDERER_JPGRAPH |
||
194 | * |
||
195 | * @return bool Success or failure |
||
196 | */ |
||
197 | 3 | public static function setChartRendererName($libraryName) |
|
206 | |||
207 | /** |
||
208 | * Tell PhpSpreadsheet where to find the external library to use for rendering charts. |
||
209 | * |
||
210 | * @param string $libraryBaseDir Directory path to the library's base folder |
||
211 | * |
||
212 | * @return bool Success or failure |
||
213 | */ |
||
214 | 3 | public static function setChartRendererPath($libraryBaseDir) |
|
223 | |||
224 | /** |
||
225 | * Return the Chart Rendering Library that PhpSpreadsheet is currently configured to use (e.g. jpgraph). |
||
226 | * |
||
227 | * @return string|null Internal reference name of the Chart Rendering Library that PhpSpreadsheet is |
||
228 | * currently configured to use |
||
229 | * e.g. \PhpOffice\PhpSpreadsheet\Settings::CHART_RENDERER_JPGRAPH |
||
230 | */ |
||
231 | public static function getChartRendererName() |
||
235 | |||
236 | /** |
||
237 | * Return the directory path to the Chart Rendering Library that PhpSpreadsheet is currently configured to use. |
||
238 | * |
||
239 | * @return string|null Directory Path to the Chart Rendering Library that PhpSpreadsheet is |
||
240 | * currently configured to use |
||
241 | */ |
||
242 | public static function getChartRendererPath() |
||
246 | |||
247 | /** |
||
248 | * Identify to PhpSpreadsheet the external library to use for rendering PDF files. |
||
249 | * |
||
250 | * @param string $libraryName Internal reference name of the library |
||
251 | * e.g. \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF, |
||
252 | * \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF |
||
253 | * or \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF |
||
254 | */ |
||
255 | 5 | public static function setPdfRendererName($libraryName) |
|
262 | |||
263 | /** |
||
264 | * Return the PDF Rendering Library that PhpSpreadsheet is currently configured to use (e.g. dompdf). |
||
265 | * |
||
266 | * @return string|null Internal reference name of the PDF Rendering Library that PhpSpreadsheet is |
||
267 | * currently configured to use |
||
268 | * e.g. \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF, |
||
269 | * \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF |
||
270 | * or \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF |
||
271 | */ |
||
272 | 4 | public static function getPdfRendererName() |
|
276 | |||
277 | /** |
||
278 | * Set default options for libxml loader. |
||
279 | * |
||
280 | * @param int $options Default options for libxml loader |
||
281 | */ |
||
282 | 14 | public static function setLibXmlLoaderOptions($options = null) |
|
290 | |||
291 | /** |
||
292 | * Get default options for libxml loader. |
||
293 | * Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly. |
||
294 | * |
||
295 | * @return int Default options for libxml loader |
||
296 | */ |
||
297 | 15 | public static function getLibXmlLoaderOptions() |
|
308 | } |
||
309 |
If you suppress an error, we recommend checking for the error condition explicitly: