From f6c0270d40f6730fe1e1820f2866b08792df1db6 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sat, 10 Dec 2016 18:22:34 +0100 Subject: rewrite data-model so that every configuration option is accessed through the conference --- model/ModelBase.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'model/ModelBase.php') diff --git a/model/ModelBase.php b/model/ModelBase.php index 7b1370b..41f329b 100644 --- a/model/ModelBase.php +++ b/model/ModelBase.php @@ -2,14 +2,17 @@ class ModelBase { - protected function has($keychain) + protected $config; + public function __construct($config) { - return ModelBase::_has($GLOBALS['CONFIG'], $keychain); + $this->config = $config; } - protected static function staticHas($keychain) + + public function has($keychain) { - return ModelBase::_has($GLOBALS['CONFIG'], $keychain); + return ModelBase::_has($this->config, $keychain); } + private static function _has($array, $keychain) { if(!is_array($keychain)) @@ -25,14 +28,11 @@ class ModelBase return ModelBase::_has($array[$key], array_slice($keychain, 1)); } - protected function get($keychain, $default = null) + public function get($keychain, $default = null) { - return ModelBase::_get($GLOBALS['CONFIG'], $keychain, $default); - } - protected static function staticGet($keychain, $default = null) - { - return ModelBase::_get($GLOBALS['CONFIG'], $keychain, $default); + return ModelBase::_get($this->config, $keychain, $default); } + private static function _get($array, $keychain, $default) { if(!is_array($keychain)) -- cgit v1.2.3