mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
allow ini files to have separators between sections for better readability
dump now makes spaces between sections in init files
This commit is contained in:
parent
1cc82ff39f
commit
5a8092fc1b
2 changed files with 7 additions and 1 deletions
|
@ -173,8 +173,10 @@ class IniReader implements ConfigReaderInterface {
|
||||||
public function dump($filename, $data) {
|
public function dump($filename, $data) {
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
|
$isSection = false;
|
||||||
if ($key[0] != '[') {
|
if ($key[0] != '[') {
|
||||||
$result[] = "[$key]";
|
$result[] = "[$key]";
|
||||||
|
$isSection = true;
|
||||||
}
|
}
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$keyValues = Hash::flatten($value, '.');
|
$keyValues = Hash::flatten($value, '.');
|
||||||
|
@ -182,8 +184,11 @@ class IniReader implements ConfigReaderInterface {
|
||||||
$result[] = "$k = " . $this->_value($v);
|
$result[] = "$k = " . $this->_value($v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($isSection) {
|
||||||
|
$result[] = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$contents = implode("\n", $result);
|
$contents = trim(implode("\n", $result));
|
||||||
|
|
||||||
if (substr($filename, -4) !== '.ini') {
|
if (substr($filename, -4) !== '.ini') {
|
||||||
$filename .= '.ini';
|
$filename .= '.ini';
|
||||||
|
|
|
@ -261,6 +261,7 @@ three.four = value four
|
||||||
is_null = null
|
is_null = null
|
||||||
bool_false = false
|
bool_false = false
|
||||||
bool_true = true
|
bool_true = true
|
||||||
|
|
||||||
[Asset]
|
[Asset]
|
||||||
timestamp = force
|
timestamp = force
|
||||||
INI;
|
INI;
|
||||||
|
|
Loading…
Add table
Reference in a new issue