Kohana_Config

Class Contents

Constants

  • None

Properties

  • None

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

Methods

public attach( )
Kohana_Config

Source Code
public function attach(Kohana_Config_Reader $reader, $first = TRUE)
{
	if ($first === TRUE)
	{
		// Place the log reader at the top of the stack
		array_unshift($this->_readers, $reader);
	}
	else
	{
		// Place the reader at the bottom of the stack
		$this->_readers[] = $reader;
	}

	return $this;
}

public copy( )
Kohana_Config

Source Code
public function copy($group)
{
	// Load the configuration group
	$config = $this->load($group);

	foreach ($this->_readers as $reader)
	{
		if ($config instanceof $reader)
		{
			// Do not copy the config to the same group
			continue;
		}

		// Load the configuration object
		$object = $reader->load($group, array());

		foreach ($config as $key => $value)
		{
			// Copy each value in the config
			$object->offsetSet($key, $value);
		}
	}

	return $this;
}

public detach( )
Kohana_Config

Source Code
public function detach(Kohana_Config_Reader $reader)
{
	if (($key = array_search($reader, $this->_readers)) !== FALSE)
	{
		// Remove the writer
		unset($this->_readers[$key]);
	}

	return $this;
}

public static instance( )
Kohana_Config

Source Code
public static function instance()
{
	if (self::$_instance === NULL)
	{
		// Create a new instance
		self::$_instance = new self;
	}

	return self::$_instance;
}

public load( )
Kohana_Config

Source Code
public function load($group)
{
	foreach ($this->_readers as $reader)
	{
		if ($config = $reader->load($group))
		{
			// Found a reader for this configuration group
			return $config;
		}
	}

	// Reset the iterator
	reset($this->_readers);

	if ( ! is_object($config = current($this->_readers)))
	{
		throw new Kohana_Exception('No configuration readers attached');
	}

	// Load the reader as an empty array
	return $config->load($group, array());
}