Skip to content
Browse files

allow ini files to have separators between sections for better readab…

…ility

dump now makes spaces between sections in init files
  • Loading branch information...
1 parent 1cc82ff commit 5a8092fc1b1ba8fc51069e34c5cfca363e4db399 @dereuromark dereuromark committed Oct 18, 2012
Showing with 7 additions and 1 deletion.
  1. +6 −1 lib/Cake/Configure/IniReader.php
  2. +1 −0 lib/Cake/Test/Case/Configure/IniReaderTest.php
View
7 lib/Cake/Configure/IniReader.php
@@ -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';
View
1 lib/Cake/Test/Case/Configure/IniReaderTest.php
@@ -261,6 +261,7 @@ public function testDump() {
is_null = null
bool_false = false
bool_true = true
+
[Asset]
timestamp = force
INI;

0 comments on commit 5a8092f

Please sign in to comment.
Something went wrong with that request. Please try again.