Vesthelm Engine

2.1.1 User Guide

Config Class

The Config class provides a means to retrieve configuration preferences.

Calling the Config Class

$Config = $this->Config;

$Config = $this->Cfg;

$Config = config();

Calling the Config Methods

$this->Config->get();

$this->Cfg->get();

config()->get();

Loading the Config Groups

Vesthelm Engine automatically loads config groups when using configs in PHP files, but if you want to use configs in Javascript files, you must load them manually:

To load one of your config groups you will use the following function within the controller that needs it:

load_conf(array('general', 'seo')); //no enhancement specified so config group will be 'vesthelm'

load_conf('general, seo', 'bulletin_board'); //enhancement specified

First argument (can be string separated with comma or array) 'general' and 'seo' are the name of config groups. Second argument 'bulletin_board' is the name of the enhancement.

Getting a Config Item

To retrieve an item from your config group:

$cfg_item = conf('bulletins_per_page', 'bulletins', 'bulletin_board');

$cfg_item = $this->Config->get('bulletins_per_page', 'bulletins', 'bulletin_board');

$cfg_item = $this->Cfg->get('bulletins_per_page', 'bulletins', 'bulletin_board');

$cfg_item = config()->get('bulletins_per_page', 'bulletins', 'bulletin_board');

First argument 'bulletins_per_page' is the config group array index you want to retrieve. Second argument 'bulletins' is the name of config group. Third argument 'bulletin_board' is the name of the enhancement. Fourth argument - bool used to unserialize config item using unserialize() function if it was serialized by serialize() function.

Setting a Config Item

If you would like to dynamically set a config item or change an existing one, you can do so using:


$this->Config->set('bulletins_per_page', 10, 'bulletins', 'bulletin_board');

$this->Cfg->set('bulletins_per_page', 10, 'bulletins', 'bulletin_board');

config()->set('bulletins_per_page', 10, 'bulletins', 'bulletin_board');

First argument 'bulletins_per_page' is the config group array index you want to retrieve. Second argument '10' is new config item value. Third argument 'bulletins' is the name of config group. Fourth argument 'bulletin_board' is the name of the enhancement. Fifth argument - bool used to unserialize config item using unserialize() function if it was serialized by serialize() function.