Browsing through modExtra and Doodles I noticed that the classes modExtra and Doodles are used to hold basic config data.
I would like to do the same for my module and also use such a config class for config data which is stored in the System Settings, so that I only have to access the settings once when the config class is created. The different settings can then be made available through specific convenience methods. As an example:
//in the initialize method of my config object:
$config = $modx->getConfig();
$this->currency = $config['currency'];
...etc...
//a convenience method:
public function getCurrency() {
return $this->currency;
}
To access the config object, I was thinking of doing the following in the initialise method of the config object:
Using the capabilities of PHP to dynamically create instance variables, I would have access to my config throughout the PHP layer of my module.
Is this considered "good behaviour" in MODx or are there better ways of achieving the above?