public function mapConfig(array $config, $mapper)
    {
        $mapperCallable = is_callable($mapper);
        if (!$mapperCallable && !$mapper instanceof ConfigurationMapperInterface) {
            throw new InvalidArgumentException('Configuration mapper must either be a callable or an instance of ConfigurationMapper.');
        }

        if ($mapper instanceof HookableConfigurationMapperInterface) {
            $mapper->preMap($config, $this->contextualizer);
        }

        $scopeNodeName = $this->contextualizer->getSiteAccessNodeName();
        foreach ($config[$scopeNodeName] as $currentScope => &$scopeSettings) {
            if ($mapperCallable) {
                call_user_func_array($mapper, array(&$scopeSettings, $currentScope, $this->contextualizer));
            } else {
                $mapper->mapConfig($scopeSettings, $currentScope, $this->contextualizer);
            }
        }

        if ($mapper instanceof HookableConfigurationMapperInterface) {
            $mapper->postMap($config, $this->contextualizer);
        }
    }