1 | <?php |
||
19 | class Ini extends ZendConfig |
||
20 | { |
||
21 | /** |
||
22 | * StringHandle that separates nesting levels of configuration data identifiers |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $nestSeparator = '.'; |
||
27 | |||
28 | /** |
||
29 | * StringHandle that separates the parent section name |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $sectionSeparator = ':'; |
||
34 | |||
35 | /** |
||
36 | * Whether to skip extends or not |
||
37 | * |
||
38 | * @var boolean |
||
39 | */ |
||
40 | protected $skipExtends = false; |
||
41 | |||
42 | /** |
||
43 | * Loads the section $section from the config file $filename for |
||
44 | * access facilitated by nested object properties. |
||
45 | * |
||
46 | * If the section name contains a ":" then the section name to the right |
||
47 | * is loaded and included into the properties. Note that the keys in |
||
48 | * this $section will override any keys of the same |
||
49 | * name in the sections that have been included via ":". |
||
50 | * |
||
51 | * If the $section is null, then all sections in the ini file are loaded. |
||
52 | * |
||
53 | * If any key includes a ".", then this will act as a separator to |
||
54 | * create a sub-property. |
||
55 | * |
||
56 | * example ini file: |
||
57 | * [all] |
||
58 | * db.connection = database |
||
59 | * hostname = live |
||
60 | * |
||
61 | * [staging : all] |
||
62 | * hostname = staging |
||
63 | * |
||
64 | * after calling $data = new Zend_Config_Ini($file, 'staging'); then |
||
65 | * $data->hostname === "staging" |
||
66 | * $data->db->connection === "database" |
||
67 | * |
||
68 | * The $options parameter may be provided as either a boolean or an array. |
||
69 | * If provided as a boolean, this sets the $allowModifications option of |
||
70 | * Zend_Config. If provided as an array, there are three configuration |
||
71 | * directives that may be set. For example: |
||
72 | * |
||
73 | * $options = array( |
||
74 | * 'allowModifications' => false, |
||
75 | * 'nestSeparator' => ':', |
||
76 | * 'skipExtends' => false, |
||
77 | * ); |
||
78 | * |
||
79 | * @param string $filename |
||
80 | * @param mixed $section |
||
81 | * @param boolean|array $options |
||
82 | * @throws Exception |
||
83 | */ |
||
84 | public function __construct($filename, $section = null, $options = false) |
||
138 | |||
139 | /** |
||
140 | * Load the INI file from disk using parse_ini_file(). Use a private error |
||
141 | * handler to convert any loading errors into a Zend_Config_Exception |
||
142 | * |
||
143 | * @param string $filename |
||
144 | * @throws Exception |
||
145 | * @return array |
||
146 | */ |
||
147 | protected function parseIniFile($filename) |
||
160 | |||
161 | /** |
||
162 | * Load the ini file and preprocess the section separator (':' in the |
||
163 | * section name (that is used for section extension) so that the resultant |
||
164 | * array has the correct section names and the extension information is |
||
165 | * stored in a sub-key called ';extends'. We use ';extends' as this can |
||
166 | * never be a valid key name in an INI file that has been loaded using |
||
167 | * parse_ini_file(). |
||
168 | * |
||
169 | * @param string $filename |
||
170 | * @throws Exception |
||
171 | * @return array |
||
172 | */ |
||
173 | protected function loadIniFile($filename) |
||
197 | |||
198 | /** |
||
199 | * Process each element in the section and handle the ";extends" inheritance |
||
200 | * key. Passes control to processKey() to handle the nest separator |
||
201 | * sub-property syntax that may be used within the key name. |
||
202 | * |
||
203 | * @param array $iniArray |
||
204 | * @param string $section |
||
205 | * @param array $config |
||
206 | * @throws Exception |
||
207 | * @return array |
||
208 | */ |
||
209 | protected function processSection($iniArray, $section, $config = array()) |
||
230 | |||
231 | /** |
||
232 | * Assign the key's value to the property list. Handles the |
||
233 | * nest separator for sub-properties. |
||
234 | * |
||
235 | * @param array $config |
||
236 | * @param string $key |
||
237 | * @param string $value |
||
238 | * @throws Exception |
||
239 | * @return array |
||
240 | */ |
||
241 | protected function processKey($config, $key, $value) |
||
265 | } |
||
266 |