PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / trunk
Matomo Analytics – Powerful, Privacy-First Insights for WordPress vtrunk
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 1 year ago GlobalSettingsProvider.php 2 years ago PluginList.php 1 month ago
GlobalSettingsProvider.php
98 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 */
9 namespace Piwik\Application\Kernel;
10
11 use Piwik\Config;
12 use Piwik\Config\IniFileChain;
13 /**
14 * Provides global settings. Global settings are organized in sections where
15 * each section contains a list of name => value pairs. Setting values can
16 * be primitive values or arrays of primitive values.
17 *
18 * Uses the config.ini.php, common.ini.php and global.ini.php files to provide global settings.
19 *
20 * At the moment a singleton instance of this class is used in order to get tests to pass.
21 */
22 class GlobalSettingsProvider
23 {
24 /**
25 * @var IniFileChain
26 */
27 protected $iniFileChain;
28 /**
29 * @var string
30 */
31 protected $pathGlobal = null;
32 /**
33 * @var string
34 */
35 protected $pathCommon = null;
36 /**
37 * @var string
38 */
39 protected $pathLocal = null;
40 /**
41 * @param string|null $pathGlobal Path to the global.ini.php file. Or null to use the default.
42 * @param string|null $pathLocal Path to the config.ini.php file. Or null to use the default.
43 * @param string|null $pathCommon Path to the common.ini.php file. Or null to use the default.
44 */
45 public function __construct($pathGlobal = null, $pathLocal = null, $pathCommon = null)
46 {
47 $this->pathGlobal = $pathGlobal ?: Config::getGlobalConfigPath();
48 $this->pathCommon = $pathCommon ?: Config::getCommonConfigPath();
49 $this->pathLocal = $pathLocal ?: Config::getLocalConfigPath();
50 $this->iniFileChain = new IniFileChain();
51 $this->reload();
52 }
53 public function reload($pathGlobal = null, $pathLocal = null, $pathCommon = null)
54 {
55 $this->pathGlobal = $pathGlobal ?: $this->pathGlobal;
56 $this->pathCommon = $pathCommon ?: $this->pathCommon;
57 $this->pathLocal = $pathLocal ?: $this->pathLocal;
58 $this->iniFileChain->reload(array($this->pathGlobal, $this->pathCommon), $this->pathLocal);
59 }
60 /**
61 * Returns a settings section.
62 *
63 * @param string $name
64 * @return array
65 */
66 public function &getSection($name)
67 {
68 $section =& $this->iniFileChain->get($name);
69 return $section;
70 }
71 /**
72 * Sets a settings section.
73 *
74 * @param string $name
75 * @param array $value
76 */
77 public function setSection($name, $value)
78 {
79 $this->iniFileChain->set($name, $value);
80 }
81 public function getIniFileChain()
82 {
83 return $this->iniFileChain;
84 }
85 public function getPathGlobal()
86 {
87 return $this->pathGlobal;
88 }
89 public function getPathLocal()
90 {
91 return $this->pathLocal;
92 }
93 public function getPathCommon()
94 {
95 return $this->pathCommon;
96 }
97 }
98