Skip to content

Commit

Permalink
allow ini files to have separators between sections for better readab…
Browse files Browse the repository at this point in the history
…ility

dump now makes spaces between sections in init files
  • Loading branch information
euromark committed Oct 18, 2012
1 parent 1cc82ff commit 5a8092f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Cake/Configure/IniReader.php
Expand Up @@ -173,17 +173,22 @@ protected function _parseNestedValues($values) {
public function dump($filename, $data) {
$result = array();
foreach ($data as $key => $value) {
$isSection = false;
if ($key[0] != '[') {
$result[] = "[$key]";
$isSection = true;
}
if (is_array($value)) {
$keyValues = Hash::flatten($value, '.');
foreach ($keyValues as $k => $v) {
$result[] = "$k = " . $this->_value($v);
}
}
if ($isSection) {
$result[] = '';
}
}
$contents = implode("\n", $result);
$contents = trim(implode("\n", $result));

if (substr($filename, -4) !== '.ini') {
$filename .= '.ini';
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/Configure/IniReaderTest.php
Expand Up @@ -261,6 +261,7 @@ public function testDump() {
is_null = null
bool_false = false
bool_true = true
[Asset]
timestamp = force
INI;
Expand Down

0 comments on commit 5a8092f

Please sign in to comment.