public function testMultilineValues() { $config = <<<'EOD' [section] key1 = "with some newline in the value" EOD; $doc = IniParser::parseIni($config); $this->assertEquals(2, count(explode("\n", $doc->getSection('section')->getDirective('key1')->getValue())), 'IniParser does not recognize multi-line values'); }
/** * Load preferences from source * * @return array * * @throws NotReadableError When the INI file of the user exists and is not readable */ public function load() { if (file_exists($this->preferencesFile)) { if (!is_readable($this->preferencesFile)) { throw new NotReadableError('Preferences INI file %s for user %s is not readable', $this->preferencesFile, $this->getUser()->getUsername()); } else { $this->preferences = IniParser::parseIniFile($this->preferencesFile)->toArray(); } } return $this->preferences; }
/** * Render the Zend_Config into a config filestring * * @return string */ public function render() { if (file_exists($this->filename)) { $oldconfig = Config::fromIni($this->filename); $content = trim(file_get_contents($this->filename)); } else { $oldconfig = Config::fromArray(array()); $content = ''; } $doc = IniParser::parseIni($content); $this->diffPropertyUpdates($this->config, $doc); $this->diffPropertyDeletions($oldconfig, $this->config, $doc); $doc = $this->updateSectionOrder($this->config, $doc); return $doc->render(); }
/** * Load configuration from the given INI file * * @param string $file The file to parse * * @throws NotReadableError When the file cannot be read */ public static function fromIni($file) { $emptyConfig = new static(); $filepath = realpath($file); if ($filepath === false) { $emptyConfig->setConfigFile($file); } elseif (is_readable($filepath)) { return IniParser::parseIniFile($filepath); } elseif (@file_exists($filepath)) { throw new NotReadableError(t('Cannot read config file "%s". Permission denied'), $filepath); } return $emptyConfig; }