mako\Config


Description


Config class.


Class methods


Toggle source

protected __construct()


Protected constructor since this is a static class.

Return value

NULL

protected function __construct()
{
	// Nothing here
}

Toggle source

public static get($key, $default = NULL)


Returns config value or entire config array from a file.


Parameters

Type Description
string Config key
mixed (optional) Default value to return if config value doesn't exist
Return value

mixed

public static function get($key, $default = null)
{
	$keys = explode('.', $key, 2);

	if(!isset(static::$config[$keys[0]]))
	{
		$path = Mako::path('config', $keys[0]);

		if(file_exists($path) === false)
		{
			throw new RuntimeException(vsprintf("%s(): The '%s' config file does not exist.", array(__METHOD__, $keys[0])));
		}	

		static::$config[$keys[0]] = include($path);
	}

	if(!isset($keys[1]))
	{
		return static::$config[$keys[0]];
	}
	else
	{
		return Arr::get(static::$config[$keys[0]], $keys[1], $default);
	}
}

Toggle source

public static set($key, $value)


Sets a config value.


Parameters

Type Description
string Config key
mixed Config value
Return value

NULL

public static function set($key, $value)
{
	$config = strtok($key, '.');

	if(!isset(static::$config[$config]))
	{
		static::get($config);
	}

	Arr::set(static::$config, $key, $value);
}

Toggle source

public static delete($key)


Deletes a value from the configuration.


Parameters

Type Description
string Config key
Return value

boolean

public static function delete($key)
{
	return Arr::delete(static::$config, $key);
}