Kohana_Config_Group
extends ArrayObject
Implements: Countable | Serializable | ArrayAccess | Traversable | IteratorAggregate
The group wrapper acts as an interface to all the config directives gathered from across the system.
This is the object returned from Kohana_Config::load
Any modifications to configuration items should be done through an instance of this object
Constants
Properties
Methods
- __construct()
- __toString()
- as_array()
- get()
- group_name()
- offsetSet()
- set()
- append()
- asort()
- count()
- exchangeArray()
- getArrayCopy()
- getFlags()
- getIterator()
- getIteratorClass()
- ksort()
- natcasesort()
- natsort()
- offsetExists()
- offsetGet()
- offsetUnset()
- serialize()
- setFlags()
- setIteratorClass()
- uasort()
- uksort()
- unserialize()
Constants
-
STD_PROP_LIST
integer 1
-
ARRAY_AS_PROPS
integer 2
Properties
-
protected string $_group_name
-
The group this config is for Used when updating config items
-
Default value:
string(0) ""
-
protected Kohana_Config $_parent_instance
-
Reference the config object that created this group Used when updating config
-
Default value:
NULL
Methods
public __construct(Kohana_Config <span class="param" title=""Owning" instance of Kohana_Config">$instance</span> , string $group [, array $config = array(0) ] ) (defined in Kohana_Config_Group)
Constructs the group object. Kohana_Config passes the config group and its config items to the object here.
Parameters
- Kohana_Config $instance required - "Owning" instance of Kohana_Config
- string $group required - The group name
- array $config = array(0) - Group's config
Source Code
public function __construct(Kohana_Config $instance, $group, array $config = [])
{
$this->_parent_instance = $instance;
$this->_group_name = $group;
parent::__construct($config, ArrayObject::ARRAY_AS_PROPS);
}
public __toString() (defined in Kohana_Config_Group)
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_Group)
Alias for getArrayCopy()
Return Values
- array - Array copy of the group's config
Source Code
public function as_array()
{
return $this->getArrayCopy();
}
public get(string $key [, mixed $default = NULL ] ) (defined in Kohana_Config_Group)
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 group_name() (defined in Kohana_Config_Group)
Returns the config group's name
Return Values
- string - The group name
Source Code
public function group_name()
{
return $this->_group_name;
}
public offsetSet(string $key , mixed $value ) (defined in Kohana_Config_Group)
Overrides ArrayObject::offsetSet() This method is called when config is changed via
$config->var = 'asd';
// OR
$config['var'] = 'asd';
Parameters
- string $key required - The key of the config item we're changing
- mixed $value required - The new array value
Source Code
public function offsetSet($key, $value)
{
$this->_parent_instance->_write_config($this->_group_name, $key, $value);
return parent::offsetSet($key, $value);
}
public set(string $key , mixed $value ) (defined in Kohana_Config_Group)
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;
}