From 904fd2d5dc907d658b6a160f80b68ec28b729bad Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Wed, 27 Feb 2013 13:33:36 +1300 Subject: [PATCH] API Make Object::config use late static binding Can now be used in instance scope, like: $this->config()->db and in static scope, like: Page::config()->db --- core/Object.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/core/Object.php b/core/Object.php index bfe7daca5..f313eb9c1 100755 --- a/core/Object.php +++ b/core/Object.php @@ -52,23 +52,12 @@ abstract class Object { */ public $class; - - /** - * @todo Set this via dependancy injection? Can't call it $config, because too many clashes with form elements etc - * @var Config_ForClass - */ - private $_config_forclass = null; - /** * Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....). * @return Config_ForClass|null */ - public function config() { - if (!$this->_config_forclass) { - $this->_config_forclass = Config::inst()->forClass($this->class); - } - - return $this->_config_forclass; + static public function config() { + return Config::inst()->forClass(get_called_class()); } /**