Modules

Kohana_Config_File
extends Config_Reader
extends Kohana_Config_Reader
extends ArrayObject

Implements: Countable | Serializable | ArrayAccess | Traversable | IteratorAggregate

File-based configuration reader. Multiple configuration directories can be used by attaching multiple instances of this class to Config.

package
Kohana
category
Configuration
author
Kohana Team
copyright
© 2009-2012 Kohana Team
license
http://kohanaframework.org/license

Class declared in SYSPATH/classes/kohana/config/file.php on line 12.

Constants

STD_PROP_LIST

integer 1

ARRAY_AS_PROPS

integer 2

Properties

protected string $_configuration_group

Configuration group name

protected bool $_configuration_modified

Has 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;
}

public append( ) (defined in ArrayObject)

public asort( ) (defined in ArrayObject)

public count( ) (defined in ArrayObject)

public exchangeArray( ) (defined in ArrayObject)

public getArrayCopy( ) (defined in ArrayObject)

public getFlags( ) (defined in ArrayObject)

public getIterator( ) (defined in ArrayObject)

public getIteratorClass( ) (defined in ArrayObject)

public ksort( ) (defined in ArrayObject)

public natcasesort( ) (defined in ArrayObject)

public natsort( ) (defined in ArrayObject)

public offsetExists( ) (defined in ArrayObject)

public offsetGet( ) (defined in ArrayObject)

public offsetSet( ) (defined in ArrayObject)

public offsetUnset( ) (defined in ArrayObject)

public serialize( ) (defined in ArrayObject)

public setFlags( ) (defined in ArrayObject)

public setIteratorClass( ) (defined in ArrayObject)

public uasort( ) (defined in ArrayObject)

public uksort( ) (defined in ArrayObject)

public unserialize( ) (defined in ArrayObject)