mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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
This commit is contained in:
parent
3f2b6a518f
commit
600d9cff53
@ -52,23 +52,12 @@ abstract class Object {
|
|||||||
*/
|
*/
|
||||||
public $class;
|
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, .....).
|
* Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
|
||||||
* @return Config_ForClass|null
|
* @return Config_ForClass|null
|
||||||
*/
|
*/
|
||||||
public function config() {
|
static public function config() {
|
||||||
if (!$this->_config_forclass) {
|
return Config::inst()->forClass(get_called_class());
|
||||||
$this->_config_forclass = Config::inst()->forClass($this->class);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_config_forclass;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user