Modules
Kohana_Config_File
extends Kohana_Config_Reader
extends ArrayObject
File-based configuration reader. Multiple configuration directories can be used by attaching multiple instances of this class to Kohana_Config.
Class declared in SYSPATH/classes/kohana/config/file.php on line 12.
Constants
Properties
Methods
- __construct()
- load()
- __toString()
- as_array()
- get()
- set()
- append()
- asort()
- count()
- exchangeArray()
- getArrayCopy()
- getFlags()
- getIterator()
- getIteratorClass()
- ksort()
- natcasesort()
- natsort()
- offsetExists()
- offsetGet()
- offsetSet()
- offsetUnset()
- serialize()
- setFlags()
- setIteratorClass()
- uasort()
- uksort()
- unserialize()
Constants
STD_PROP_LIST
integer 1
ARRAY_AS_PROPS
integer 2
Properties
protected
string$_configuration_groupConfiguration group name
protected
bool$_configuration_modifiedHas the config group changed?
Methods
public __construct( ) (defined in Kohana_Config_File)
Loads an empty array as the initial configuration and enables array keys to be used as properties.
Return Values
void
Source Code
public function __construct($directory = 'config')
{
// Set the configuration directory name
$this->_directory = trim($directory, '/');
// Load the empty array
parent::__construct();
}
public load( string $group [, array $config = NULL ] ) (defined in Kohana_Config_File)
Load and merge all of the configuration files in this group.
$config->load($name);
Parameters
-
string$group required - Configuration group name -
array$config = NULL - Configuration array
Tags
Return Values
$this- Clone of the current object
Source Code
public function load($group, array $config = NULL)
{
if ($files = Kohana::find_file($this->_directory, $group, NULL, TRUE))
{
// Initialize the config array
$config = array();
foreach ($files as $file)
{
// Merge each file to the configuration array
$config = Arr::merge($config, Kohana::load($file));
}
}
return parent::load($group, $config);
}
public __toString( ) (defined in Kohana_Config_Reader)
Return the current group in serialized form.
echo $config;
Return Values
string
Source Code
public function __toString()
{
return serialize($this->getArrayCopy());
}
public as_array( ) (defined in Kohana_Config_Reader)
Return the raw array that is being used for this object.
$array = $config->as_array();
Return Values
array
Source Code
public function as_array()
{
return $this->getArrayCopy();
}
public get( string $key [, mixed $default = NULL ] ) (defined in Kohana_Config_Reader)
Get a variable from the configuration or return the default value.
$value = $config->get($key);
Parameters
-
string$key required - Array key -
mixed$default = NULL - Default value
Return Values
mixed
Source Code
public function get($key, $default = NULL)
{
return $this->offsetExists($key) ? $this->offsetGet($key) : $default;
}
public set( string $key , mixed $value ) (defined in Kohana_Config_Reader)
Sets a value in the configuration array.
$config->set($key, $new_value);
Parameters
-
string$key required - Array key -
mixed$value required - Array value
Return Values
$this
Source Code
public function set($key, $value)
{
$this->offsetSet($key, $value);
return $this;
}