Webiny\Component\ServiceManager\ConfigCompiler::extendConfig PHP Method

extendConfig() private method

Extend $config with $parentConfig
private extendConfig ( ArrayObject $config, ArrayObject $parentConfig ) : ArrayObject
$config Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject Child config object
$parentConfig Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject Parent config object
return Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject
    private function extendConfig(ArrayObject $config, ArrayObject $parentConfig)
    {
        $configCalls = null;
        $overrideCalls = false;
        // Get calls arrays
        if ($config->keyExists('Calls')) {
            $configCalls = $config->key('Calls');
        } elseif ($config->keyExists('!Calls')) {
            $configCalls = $config->key('!Calls');
            $overrideCalls = true;
        }
        $parentCalls = $parentConfig->key('Calls', [], true);
        // Merge basic values
        $config = $parentConfig->merge($config);
        // Remove unnecessary keys
        $config->removeKey('Parent')->removeKey('Abstract')->removeKey('Calls');
        // Merge calls
        if (!$this->isNull($configCalls) && !$this->isNull($parentCalls)) {
            if ($overrideCalls) {
                $config->key('!Calls', $configCalls);
                return;
            }
            foreach ($configCalls as $call) {
                $call = $this->arr($call);
                if ($call->keyExists(2)) {
                    $parentCalls[$call[2]] = $call->val();
                } else {
                    $parentCalls[] = $call->val();
                }
            }
            $config->key('Calls', $parentCalls);
        } elseif ($this->isNull($configCalls) && !$this->isNull($parentCalls)) {
            $config->key('Calls', $parentCalls);
        } elseif (!$this->isNull($configCalls) && $this->isNull($parentCalls)) {
            $config->key('Calls', $configCalls);
        }
        return $config;
    }