mirror of
https://github.com/getgrav/grav.git
synced 2026-07-11 11:33:16 +02:00
Allow Utils::setDotNotation to merge data, rather than just set.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
* Added support for `self@`, `page@`, `taxonomy@`, `root@` Collection syntax for cleaner YAML compatibility
|
||||
* Improved GPM commands to allow for `-y` to automate **yes** responses and `-o` for **update** and **selfupgrade** to overwrite installations [#985](https://github.com/getgrav/grav/issues/985)
|
||||
* Added randomization to `safe_email` Twig filter for greater security [#998](https://github.com/getgrav/grav/issues/998)
|
||||
* Allow `Utils::setDotNotation` to merge data, rather than just set
|
||||
1. [](#bugfix)
|
||||
* Removed 307 redirect code option as it is not well supported [#743](https://github.com/getgrav/grav-plugin-admin/issues/743)
|
||||
* Fixed issue with folders with name `*.md` are not confused with pages [#995](https://github.com/getgrav/grav/issues/995)
|
||||
|
||||
@@ -711,12 +711,14 @@ abstract class Utils
|
||||
* Set portion of array (passed by reference) for a dot-notation key
|
||||
* and set the value
|
||||
*
|
||||
* @param $array
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @param $array
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @param bool $merge
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function setDotNotation(&$array, $key, $value)
|
||||
public static function setDotNotation(&$array, $key, $value, $merge = false)
|
||||
{
|
||||
if (is_null($key)) return $array = $value;
|
||||
|
||||
@@ -734,7 +736,14 @@ abstract class Utils
|
||||
$array =& $array[$key];
|
||||
}
|
||||
|
||||
$array[array_shift($keys)] = $value;
|
||||
$key = array_shift($keys);
|
||||
|
||||
if (!$merge || !isset($array[$key])) {
|
||||
$array[$key] = $value;
|
||||
} else {
|
||||
$array[$key] = array_merge($array[$key], $value);
|
||||
}
|
||||
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user