PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.19
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.19
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / vendor / openspout / openspout / src / Reader / ODS / Helper / SettingsHelper.php

SettingsHelper.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.19, at vendor/openspout/openspout/src/Reader/ODS/Helper/SettingsHelper.php

52 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\OpenSpout\Reader\ODS\Helper;
4
5 use FluentCart\OpenSpout\Reader\Exception\XMLProcessingException;
6 use FluentCart\OpenSpout\Reader\ODS\Creator\InternalEntityFactory;
7 /**
8 * This class provides helper functions to extract data from the "settings.xml" file.
9 */
10 class SettingsHelper
11 {
12 public const SETTINGS_XML_FILE_PATH = 'settings.xml';
13 /** Definition of XML nodes name and attribute used to parse settings data */
14 public const XML_NODE_CONFIG_ITEM = 'config:config-item';
15 public const XML_ATTRIBUTE_CONFIG_NAME = 'config:name';
16 public const XML_ATTRIBUTE_VALUE_ACTIVE_TABLE = 'ActiveTable';
17 /** @var InternalEntityFactory Factory to create entities */
18 private $entityFactory;
19 /**
20 * @param InternalEntityFactory $entityFactory Factory to create entities
21 */
22 public function __construct($entityFactory)
23 {
24 $this->entityFactory = $entityFactory;
25 }
26 /**
27 * @param string $filePath Path of the file to be read
28 *
29 * @return null|string Name of the sheet that was defined as active or NULL if none found
30 */
31 public function getActiveSheetName($filePath)
32 {
33 $xmlReader = $this->entityFactory->createXMLReader();
34 if (\false === $xmlReader->openFileInZip($filePath, self::SETTINGS_XML_FILE_PATH)) {
35 return null;
36 }
37 $activeSheetName = null;
38 try {
39 while ($xmlReader->readUntilNodeFound(self::XML_NODE_CONFIG_ITEM)) {
40 if (self::XML_ATTRIBUTE_VALUE_ACTIVE_TABLE === $xmlReader->getAttribute(self::XML_ATTRIBUTE_CONFIG_NAME)) {
41 $activeSheetName = $xmlReader->readString();
42 break;
43 }
44 }
45 } catch (XMLProcessingException $exception) {
46 // do nothing
47 }
48 $xmlReader->close();
49 return $activeSheetName;
50 }
51 }
52