system/src/Grav/Common/Plugin.php
/**
     * Merge global and page configurations.
     *
     * @param Page  $page    The page to merge the configurations with the
     *                       plugin settings.
     * @param bool  $deep    Should you use deep or shallow merging
     * @param array $params  Array of additional configuration options to
     *                       merge with the plugin settings.
     *
     * @return \Grav\Common\Data\Data
     */
Merge global and page configurations.
@param Page  $page    The page to merge the configurations with the
plugin settings.
@param bool  $deep    Should you use deep or shallow merging
@param array $params  Array of additional configuration options to
merge with the plugin settings.

@return \Grav\Common\Data\Data
Merge global and page configurations . @param Page $page The page to merge the configurations with the plugin settings . @param bool $deep Should you use deep or shallow merging @param array $params Array of additional configuration options to merge with the plugin settings . @return \ Grav \ Common \ Data \ Data
protected function mergeConfig(Page $page, $deep = false, $params = [])
    {
        $class_name = $this->name;
        $class_name_merged = $class_name . '.merged';
        $defaults = $this->config->get('plugins.' . $class_name, []);
        $page_header = $page->header();
        $header = [];
        if (!isset($page_header->$class_name_merged) && isset($page_header->$class_name)) {
            $config = $page_header->$class_name;
            if (is_bool($config)) {
                $config = ['enabled' => $config];
            }
            if ($deep) {
                $header = array_replace_recursive($defaults, $config);
            } else {
                $header = array_merge($defaults, $config);
            }
            $page->modifyHeader($class_name_merged, new Data($header));
        } else if (isset($page_header->$class_name_merged)) {
            $merged = $page_header->$class_name_merged;
            $header = $merged->toArray();
        }
        if (empty($header)) {
            $header = $defaults;
        }
        if ($deep) {
            $header = array_replace_recursive($header, $params);
        } else {
            $header = array_merge($header, $params);
        }
        return new Data($header);
    }
protected function mergeConfig ( Page $ page , $ deep = false , $ params = [ ] ) { $ class_name = $ this -> name ; $ class_name_merged = $ class_name . '.merged' ; $ defaults = $ this -> config -> get ( 'plugins.' . $ class_name , [ ] ) ; $ page_header = $ page -> header ( ) ; $ header = [ ] ; if ( ! isset ( $ page_header -> $ class_name_merged ) && isset ( $ page_header -> $ class_name ) ) { $ config = $ page_header -> $ class_name ; if ( is_bool ( $ config ) ) { $ config = [ 'enabled' => $ config ] ; } if ( $ deep ) { $ header = array_replace_recursive ( $ defaults , $ config ) ; } else { $ header = array_merge ( $ defaults , $ config ) ; } $ page -> modifyHeader ( $ class_name_merged , new Data ( $ header ) ) ; } else if ( isset ( $ page_header -> $ class_name_merged ) ) { $ merged = $ page_header -> $ class_name_merged ; $ header = $ merged -> toArray ( ) ; } if ( empty ( $ header ) ) { $ header = $ defaults ; } if ( $ deep ) { $ header = array_replace_recursive ( $ header , $ params ) ; } else { $ header = array_merge ( $ header , $ params ) ; } return new Data ( $ header ) ; }
Merge global and page configurations.
Merge global and page configurations .
// Get default plugin configurations and retrieve page header configuration // Overwrite enabled option with boolean value in page header // Merge page header settings using deep or shallow merging technique // Create new config object and set it on the page object so it's cached for next time // Merge additional parameter with configuration options // Return configurations as a new data config class