/usr/share/php/kohana3.2/system/classes/kohana/config/group.php is in libkohana3.2-core-php 3.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | <?php defined('SYSPATH') or die('No direct script access.');
/**
* 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
*
* @package Kohana
* @category Configuration
* @author Kohana Team
* @copyright (c) 2010 Kohana Team
* @license http://kohanaphp.com/license
*/
class Kohana_Config_Group extends ArrayObject {
/**
* Reference the config object that created this group
* Used when updating config
* @var Kohana_Config
*/
protected $_parent_instance = NULL;
/**
* The group this config is for
* Used when updating config items
* @var string
*/
protected $_group_name = '';
/**
* Constructs the group object. Kohana_Config passes the config group
* and its config items to the object here.
*
* @param Kohana_Config $instance "Owning" instance of Kohana_Config
* @param string $group The group name
* @param array $config Group's config
*/
public function __construct(Kohana_Config $instance, $group, array $config = array())
{
$this->_parent_instance = $instance;
$this->_group_name = $group;
parent::__construct($config, ArrayObject::ARRAY_AS_PROPS);
}
/**
* Return the current group in serialized form.
*
* echo $config;
*
* @return string
*/
public function __toString()
{
return serialize($this->getArrayCopy());
}
/**
* Alias for getArrayCopy()
*
* @return array Array copy of the group's config
*/
public function as_array()
{
return $this->getArrayCopy();
}
/**
* Returns the config group's name
*
* @return string The group name
*/
public function group_name()
{
return $this->_group_name;
}
/**
* Get a variable from the configuration or return the default value.
*
* $value = $config->get($key);
*
* @param string array key
* @param mixed default value
* @return mixed
*/
public function get($key, $default = NULL)
{
return $this->offsetExists($key) ? $this->offsetGet($key) : $default;
}
/**
* Sets a value in the configuration array.
*
* $config->set($key, $new_value);
*
* @param string array key
* @param mixed array value
* @return $this
*/
public function set($key, $value)
{
$this->offsetSet($key, $value);
return $this;
}
/**
* Overrides ArrayObject::offsetSet()
* This method is called when config is changed via
*
* $config->var = 'asd';
*
* // OR
*
* $config['var'] = 'asd';
*
* @param string $key The key of the config item we're changing
* @param mixed $value The new array value
*/
public function offsetSet($key, $value)
{
$this->_parent_instance->_write_config($this->_group_name, $key, $value);
return parent::offsetSet($key, $value);
}
}
|