12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Config |
16 * @package Zend_Config |
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: Ini.php 20096 2010-01-06 02:05:09Z bkarwin $ |
19 * @version $Id: Ini.php 24593 2012-01-05 20:35:02Z matthew $ |
20 */ |
20 */ |
21 |
21 |
22 |
22 |
23 /** |
23 /** |
24 * @see Zend_Config |
24 * @see Zend_Config |
81 * $data->hostname === "staging" |
81 * $data->hostname === "staging" |
82 * $data->db->connection === "database" |
82 * $data->db->connection === "database" |
83 * |
83 * |
84 * The $options parameter may be provided as either a boolean or an array. |
84 * The $options parameter may be provided as either a boolean or an array. |
85 * If provided as a boolean, this sets the $allowModifications option of |
85 * If provided as a boolean, this sets the $allowModifications option of |
86 * Zend_Config. If provided as an array, there are two configuration |
86 * Zend_Config. If provided as an array, there are three configuration |
87 * directives that may be set. For example: |
87 * directives that may be set. For example: |
88 * |
88 * |
89 * $options = array( |
89 * $options = array( |
90 * 'allowModifications' => false, |
90 * 'allowModifications' => false, |
91 * 'nestSeparator' => '->' |
91 * 'nestSeparator' => ':', |
|
92 * 'skipExtends' => false, |
92 * ); |
93 * ); |
93 * |
94 * |
94 * @param string $filename |
95 * @param string $filename |
95 * @param string|null $section |
96 * @param mixed $section |
96 * @param boolean|array $options |
97 * @param boolean|array $options |
97 * @throws Zend_Config_Exception |
98 * @throws Zend_Config_Exception |
98 * @return void |
99 * @return void |
99 */ |
100 */ |
100 public function __construct($filename, $section = null, $options = false) |
101 public function __construct($filename, $section = null, $options = false) |
155 parent::__construct($dataArray, $allowModifications); |
156 parent::__construct($dataArray, $allowModifications); |
156 } |
157 } |
157 |
158 |
158 $this->_loadedSection = $section; |
159 $this->_loadedSection = $section; |
159 } |
160 } |
160 |
161 |
161 /** |
162 /** |
162 * Load the INI file from disk using parse_ini_file(). Use a private error |
163 * Load the INI file from disk using parse_ini_file(). Use a private error |
163 * handler to convert any loading errors into a Zend_Config_Exception |
164 * handler to convert any loading errors into a Zend_Config_Exception |
164 * |
165 * |
165 * @param string $filename |
166 * @param string $filename |
166 * @throws Zend_Config_Exception |
167 * @throws Zend_Config_Exception |
167 * @return array |
168 * @return array |
168 */ |
169 */ |
169 protected function _parseIniFile($filename) |
170 protected function _parseIniFile($filename) |
170 { |
171 { |
171 set_error_handler(array($this, '_loadFileErrorHandler')); |
172 set_error_handler(array($this, '_loadFileErrorHandler')); |
172 $iniArray = parse_ini_file($filename, true); // Warnings and errors are suppressed |
173 $iniArray = parse_ini_file($filename, true); // Warnings and errors are suppressed |
173 restore_error_handler(); |
174 restore_error_handler(); |
174 |
175 |
175 // Check if there was a error while loading file |
176 // Check if there was a error while loading file |
176 if ($this->_loadFileErrorStr !== null) { |
177 if ($this->_loadFileErrorStr !== null) { |
177 /** |
178 /** |
178 * @see Zend_Config_Exception |
179 * @see Zend_Config_Exception |
179 */ |
180 */ |
180 require_once 'Zend/Config/Exception.php'; |
181 require_once 'Zend/Config/Exception.php'; |
181 throw new Zend_Config_Exception($this->_loadFileErrorStr); |
182 throw new Zend_Config_Exception($this->_loadFileErrorStr); |
182 } |
183 } |
183 |
184 |
184 return $iniArray; |
185 return $iniArray; |
185 } |
186 } |
186 |
187 |
187 /** |
188 /** |
188 * Load the ini file and preprocess the section separator (':' in the |
189 * Load the ini file and preprocess the section separator (':' in the |