PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Application / Kernel / GlobalSettingsProvider.php
matomo / app / core / Application / Kernel Last commit date
EnvironmentValidator.php 6 years ago GlobalSettingsProvider.php 6 years ago PluginList.php 6 years ago
GlobalSettingsProvider.php
112 lines
1 <?php
2 /**
3 * Piwik - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 */
8
9 namespace Piwik\Application\Kernel;
10
11 use Piwik\Config;
12 use Piwik\Config\IniFileChain;
13
14 /**
15 * Provides global settings. Global settings are organized in sections where
16 * each section contains a list of name => value pairs. Setting values can
17 * be primitive values or arrays of primitive values.
18 *
19 * Uses the config.ini.php, common.ini.php and global.ini.php files to provide global settings.
20 *
21 * At the moment a singleton instance of this class is used in order to get tests to pass.
22 */
23 class GlobalSettingsProvider
24 {
25 /**
26 * @var IniFileChain
27 */
28 protected $iniFileChain;
29
30 /**
31 * @var string
32 */
33 protected $pathGlobal = null;
34
35 /**
36 * @var string
37 */
38 protected $pathCommon = null;
39
40 /**
41 * @var string
42 */
43 protected $pathLocal = null;
44
45 /**
46 * @param string|null $pathGlobal Path to the global.ini.php file. Or null to use the default.
47 * @param string|null $pathLocal Path to the config.ini.php file. Or null to use the default.
48 * @param string|null $pathCommon Path to the common.ini.php file. Or null to use the default.
49 */
50 public function __construct($pathGlobal = null, $pathLocal = null, $pathCommon = null)
51 {
52 $this->pathGlobal = $pathGlobal ?: Config::getGlobalConfigPath();
53 $this->pathCommon = $pathCommon ?: Config::getCommonConfigPath();
54 $this->pathLocal = $pathLocal ?: Config::getLocalConfigPath();
55
56 $this->iniFileChain = new IniFileChain();
57 $this->reload();
58 }
59
60 public function reload($pathGlobal = null, $pathLocal = null, $pathCommon = null)
61 {
62 $this->pathGlobal = $pathGlobal ?: $this->pathGlobal;
63 $this->pathCommon = $pathCommon ?: $this->pathCommon;
64 $this->pathLocal = $pathLocal ?: $this->pathLocal;
65
66 $this->iniFileChain->reload(array($this->pathGlobal, $this->pathCommon), $this->pathLocal);
67 }
68
69 /**
70 * Returns a settings section.
71 *
72 * @param string $name
73 * @return array
74 */
75 public function &getSection($name)
76 {
77 $section =& $this->iniFileChain->get($name);
78 return $section;
79 }
80
81 /**
82 * Sets a settings section.
83 *
84 * @param string $name
85 * @param array $value
86 */
87 public function setSection($name, $value)
88 {
89 $this->iniFileChain->set($name, $value);
90 }
91
92 public function getIniFileChain()
93 {
94 return $this->iniFileChain;
95 }
96
97 public function getPathGlobal()
98 {
99 return $this->pathGlobal;
100 }
101
102 public function getPathLocal()
103 {
104 return $this->pathLocal;
105 }
106
107 public function getPathCommon()
108 {
109 return $this->pathCommon;
110 }
111 }
112