src/SiteConfig/ConfigBuilder.php
public function mergeConfig(SiteConfig $currentConfig, SiteConfig $newConfig)
    {
        // check for commands where we accept multiple statements (no test_url)
        foreach (['title', 'body', 'strip', 'strip_id_or_class', 'strip_image_src', 'single_page_link', 'next_page_link', 'date', 'author', 'strip_attr'] as $var) {
            // append array elements for this config variable from $newConfig to this config
            $currentConfig->$var = array_unique(array_merge($currentConfig->$var, $newConfig->$var));
        }

        // special handling of if_page_contains directive
        foreach (['single_page_link'] as $var) {
            if (isset($currentConfig->if_page_contains[$var]) && isset($newConfig->if_page_contains[$var])) {
                $currentConfig->if_page_contains[$var] = array_merge($newConfig->if_page_contains[$var], $currentConfig->if_page_contains[$var]);
            } elseif (isset($newConfig->if_page_contains[$var])) {
                $currentConfig->if_page_contains[$var] = $newConfig->if_page_contains[$var];
            }
        }

        // check for single statement commands
        // we do not overwrite existing non null values
        foreach (['tidy', 'prune', 'parser', 'autodetect_on_failure', 'requires_login', 'skip_json_ld'] as $var) {
            if ($currentConfig->$var === null) {
                $currentConfig->$var = $newConfig->$var;
            }
        }

        // treat find_string and replace_string separately (don't apply array_unique) (thanks fabrizio!)
        foreach (['find_string', 'replace_string'] as $var) {
            // append array elements for this config variable from $newConfig to this config
            $currentConfig->$var = array_merge($currentConfig->$var, $newConfig->$var);
        }

        // merge http_header array from currentConfig into newConfig
        // because final values override former values in case of named keys
        $currentConfig->http_header = array_merge($newConfig->http_header, $currentConfig->http_header);

        return $currentConfig;
    }
public function mergeConfig(SiteConfig $currentConfig, SiteConfig $newConfig)
    {
        // check for commands where we accept multiple statements (no test_url)
        foreach (['title', 'body', 'strip', 'strip_id_or_class', 'strip_image_src', 'single_page_link', 'next_page_link', 'date', 'author', 'strip_attr'] as $var) {
            // append array elements for this config variable from $newConfig to this config
            $currentConfig->$var = array_unique(array_merge($currentConfig->$var, $newConfig->$var));
        }

        // special handling of if_page_contains directive
        foreach (['single_page_link'] as $var) {
            if (isset($currentConfig->if_page_contains[$var]) && isset($newConfig->if_page_contains[$var])) {
                $currentConfig->if_page_contains[$var] = array_merge($newConfig->if_page_contains[$var], $currentConfig->if_page_contains[$var]);
            } elseif (isset($newConfig->if_page_contains[$var])) {
                $currentConfig->if_page_contains[$var] = $newConfig->if_page_contains[$var];
            }
        }

        // check for single statement commands
        // we do not overwrite existing non null values
        foreach (['tidy', 'prune', 'parser', 'autodetect_on_failure', 'requires_login', 'skip_json_ld'] as $var) {
            if ($currentConfig->$var === null) {
                $currentConfig->$var = $newConfig->$var;
            }
        }

        // treat find_string and replace_string separately (don't apply array_unique) (thanks fabrizio!)
        foreach (['find_string', 'replace_string'] as $var) {
            // append array elements for this config variable from $newConfig to this config
            $currentConfig->$var = array_merge($currentConfig->$var, $newConfig->$var);
        }

        // merge http_header array from currentConfig into newConfig
        // because final values override former values in case of named keys
        $currentConfig->http_header = array_merge($newConfig->http_header, $currentConfig->http_header);

        return $currentConfig;
    }
public function mergeConfig ( SiteConfig $ currentConfig , SiteConfig $ newConfig ) { // check for commands where we accept multiple statements (no test_url) foreach ( [ 'title' , 'body' , 'strip' , 'strip_id_or_class' , 'strip_image_src' , 'single_page_link' , 'next_page_link' , 'date' , 'author' , 'strip_attr' ] as $ var ) { // append array elements for this config variable from $newConfig to this config $ currentConfig -> $ var = array_unique ( array_merge ( $ currentConfig -> $ var , $ newConfig -> $ var ) ) ; } // special handling of if_page_contains directive foreach ( [ 'single_page_link' ] as $ var ) { if ( isset ( $ currentConfig -> if_page_contains [ $ var ] ) && isset ( $ newConfig -> if_page_contains [ $ var ] ) ) { $ currentConfig -> if_page_contains [ $ var ] = array_merge ( $ newConfig -> if_page_contains [ $ var ] , $ currentConfig -> if_page_contains [ $ var ] ) ; } elseif ( isset ( $ newConfig -> if_page_contains [ $ var ] ) ) { $ currentConfig -> if_page_contains [ $ var ] = $ newConfig -> if_page_contains [ $ var ] ; } } // check for single statement commands // we do not overwrite existing non null values foreach ( [ 'tidy' , 'prune' , 'parser' , 'autodetect_on_failure' , 'requires_login' , 'skip_json_ld' ] as $ var ) { if ( $ currentConfig -> $ var === null ) { $ currentConfig -> $ var = $ newConfig -> $ var ; } } // treat find_string and replace_string separately (don't apply array_unique) (thanks fabrizio!) foreach ( [ 'find_string' , 'replace_string' ] as $ var ) { // append array elements for this config variable from $newConfig to this config $ currentConfig -> $ var = array_merge ( $ currentConfig -> $ var , $ newConfig -> $ var ) ; } // merge http_header array from currentConfig into newConfig // because final values override former values in case of named keys $ currentConfig -> http_header = array_merge ( $ newConfig -> http_header , $ currentConfig -> http_header ) ; return $ currentConfig ; }
Append a configuration from to an existing one.

@param SiteConfig $currentConfig Current configuration
@param SiteConfig $newConfig     New configuration to be merged

@return SiteConfig Merged config
Append a configuration from to an existing one .