PluginProbe
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.10.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.10.0
5.13.0 5.12.1 5.12.0 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 All 83 releases
matomo / app / core / Settings / Interfaces / Traits / Getters / ConfigGetterTrait.php
ConfigGetterTrait.php
45 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Settings\Interfaces\Traits\Getters;
10
11 use Piwik\Config;
12 use Piwik\Settings\Interfaces\ConfigSettingInterface;
13 /**
14 * @template T of mixed
15 *
16 * @phpstan-require-implements ConfigSettingInterface
17 */
18 trait ConfigGetterTrait
19 {
20 /**
21 * @return T|null
22 */
23 public static function getConfigValue(?int $idSite = null)
24 {
25 $configKey = self::getConfigSection();
26 if ($idSite !== null) {
27 $configKey .= '_' . $idSite;
28 }
29 $config = Config::getInstance()->{$configKey};
30 if (is_null($config) || !array_key_exists(self::getConfigSettingName(), $config)) {
31 return null;
32 }
33 return $config[self::getConfigSettingName()];
34 }
35 protected static abstract function getConfigSection() : string;
36 protected static abstract function getConfigSettingName() : string;
37 /**
38 * @deprecated Will be removed in 6.0 in favour of making getConfigSettingName public
39 */
40 public static function getConfigSettingShortName() : string
41 {
42 return self::getConfigSettingName();
43 }
44 }
45