/** * Returns a configuration value or section by name. * * @param string $name The value or section name. * @return string|array The requested value requested. Returned by reference. * @throws Exception If the value requested not found in either `config.ini.php` or * `global.ini.php`. * @api */ public function &__get($name) { if (!$this->initialized) { $this->reload(array($this->pathGlobal, $this->pathCommon), $this->pathLocal); // must be called here, not in init(), since setTestEnvironment() calls init(). (this avoids // infinite recursion) $allSettings =& $this->settings->getAll(); Piwik::postTestEvent('Config.createConfigSingleton', array($this, &$allSettings)); } $section =& $this->settings->get($name); return $section; }
public function test_get_ReturnsReferenceToSettingsSection_EvenIfSettingsIsEmpty() { $fileChain = new IniFileChain(array(__DIR__ . '/test_files/empty.ini.php')); $data =& $fileChain->get('Section'); $this->assertEquals(array(), $data); $data['var1'] = 'changed'; $this->assertEquals(array('var1' => 'changed'), $fileChain->get('Section')); }