commit c69f30dd4344afbe6e26c45b72b7f95c0ce4a147
parent bdc9dbc7b444c72fe83a3641b6a09d46f3138b21
Author: Jan Dankert <develop@jandankert.de>
Date: Sat, 26 Sep 2020 04:37:39 +0200
Enhanced configuration.
Diffstat:
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/modules/cms/base/Configuration.class.php b/modules/cms/base/Configuration.class.php
@@ -3,6 +3,7 @@
namespace cms\base;
use configuration\Config;
+use util\Session;
class Configuration {
@@ -13,7 +14,7 @@ class Configuration {
*/
public static function config($part1 = null, $part2 = null, $part3 = null, $part4 = null)
{
- global $conf;
+ $conf = self::getConfig();
if ($part1 == null)
return new Config($conf);
@@ -49,9 +50,23 @@ class Configuration {
public static function Conf()
{
- global $conf;
- return new Config($conf);
+ return new Config(self::getConfig() );
}
+
+ /**
+ * Gives the subset with this key.
+ * @param $key subset key
+ * @return Config
+ */
+ public static function subset( $key ) {
+ return self::Conf()->subset($key);
+ }
+
+ private static function getConfig()
+ {
+ return Session::getConfig();
+ }
+
}
diff --git a/modules/configuration/Config.class.php b/modules/configuration/Config.class.php
@@ -2,9 +2,12 @@
namespace configuration;
+/**
+ * Reading configuration values.
+ */
class Config
{
- private $config = array();
+ private $config;
/**
@@ -25,7 +28,7 @@ class Config
*/
public function subset($name)
{
- if (isset($this->config[$name]))
+ if (isset($this->config[$name]) && is_array($this->config[$name]))
return new Config($this->config[$name]);
else
return new Config(array());