From 5a8092fc1b1ba8fc51069e34c5cfca363e4db399 Mon Sep 17 00:00:00 2001 From: euromark Date: Thu, 18 Oct 2012 17:20:15 +0200 Subject: [PATCH] allow ini files to have separators between sections for better readability dump now makes spaces between sections in init files --- lib/Cake/Configure/IniReader.php | 7 ++++++- lib/Cake/Test/Case/Configure/IniReaderTest.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Configure/IniReader.php b/lib/Cake/Configure/IniReader.php index 871a8786b..af661ec86 100644 --- a/lib/Cake/Configure/IniReader.php +++ b/lib/Cake/Configure/IniReader.php @@ -173,8 +173,10 @@ class IniReader implements ConfigReaderInterface { 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, '.'); @@ -182,8 +184,11 @@ class IniReader implements ConfigReaderInterface { $result[] = "$k = " . $this->_value($v); } } + if ($isSection) { + $result[] = ''; + } } - $contents = implode("\n", $result); + $contents = trim(implode("\n", $result)); if (substr($filename, -4) !== '.ini') { $filename .= '.ini'; diff --git a/lib/Cake/Test/Case/Configure/IniReaderTest.php b/lib/Cake/Test/Case/Configure/IniReaderTest.php index 5bbbe57c1..a7e47037a 100644 --- a/lib/Cake/Test/Case/Configure/IniReaderTest.php +++ b/lib/Cake/Test/Case/Configure/IniReaderTest.php @@ -261,6 +261,7 @@ three.four = value four is_null = null bool_false = false bool_true = true + [Asset] timestamp = force INI;