Added optional deep option. defaults to false

This commit is contained in:
Andy Miller
2015-02-18 22:04:02 -07:00
parent 3e245ef686
commit 6811fbea3d

View File

@@ -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;
}