From 6811fbea3d6aca6b46407767fb22fa8c8287c1ab Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 18 Feb 2015 22:04:02 -0700 Subject: [PATCH] Added optional deep option. defaults to false --- system/src/Grav/Common/Plugin.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php index 40ae44bbe..4197dd192 100644 --- a/system/src/Grav/Common/Plugin.php +++ b/system/src/Grav/Common/Plugin.php @@ -117,12 +117,14 @@ class Plugin implements EventSubscriberInterface /** * Merge global and page configurations. * - * @param Page $page The page to merge the configurations with the + * @param Page $page The page to merge the configurations with the * plugin settings. * + * @param bool $deep Should you use deep or shallow merging + * * @return \Grav\Common\Data\Data */ - protected function mergeConfig(Page $page) + protected function mergeConfig(Page $page, $deep = false) { $class_name = $this->name; $class_name_merged = $class_name . '.merged'; @@ -140,7 +142,11 @@ class Plugin implements EventSubscriberInterface // Get default plugin configurations and retrieve page header configuration if (isset($page->header()->$class_name)) { - $header = array_replace_recursive($defaults, $page->header()->$class_name); + if ($deep) { + $header = array_replace_recursive($defaults, $page->header()->$class_name); + } else { + $header = array_merge($defaults, $page->header()->$class_name); + } } else { $header = $defaults; }