public function mapConfigArray($id, array $config, $options = 0)
{
$this->mapReservedScopeArray($id, $config, ConfigResolver::SCOPE_DEFAULT);
$this->mapReservedScopeArray($id, $config, ConfigResolver::SCOPE_GLOBAL);
$defaultSettings = $this->getContainerParameter($this->namespace . '.' . ConfigResolver::SCOPE_DEFAULT . '.' . $id, array());
$globalSettings = $this->getContainerParameter($this->namespace . '.' . ConfigResolver::SCOPE_GLOBAL . '.' . $id, array());
foreach ($this->availableSiteAccesses as $scope) {
// for a siteaccess, we have to merge the default value,
// the group value(s), the siteaccess value and the global
// value of the settings.
$groupsSettings = array();
if (isset($this->groupsBySiteAccess[$scope]) && is_array($this->groupsBySiteAccess[$scope])) {
$groupsSettings = $this->groupsArraySetting($this->groupsBySiteAccess[$scope], $id, $config, $options & static::MERGE_FROM_SECOND_LEVEL);
}
$scopeSettings = array();
if (isset($config[$this->siteAccessNodeName][$scope][$id])) {
$scopeSettings = $config[$this->siteAccessNodeName][$scope][$id];
}
if ($options & static::MERGE_FROM_SECOND_LEVEL) {
// array_merge() has to be used because we don't
// know whether we have a hash or a plain array
$keys1 = array_unique(array_merge(array_keys($defaultSettings), array_keys($groupsSettings), array_keys($scopeSettings), array_keys($globalSettings)));
$mergedSettings = array();
foreach ($keys1 as $key) {
// Only merge if actual setting is an array.
// We assume default setting to be a clear reference for this.
// If the setting is not an array, we copy the right value, in respect to the precedence:
// 1. global
// 2. SiteAccess
// 3. Group
// 4. default
if (array_key_exists($key, $defaultSettings) && !is_array($defaultSettings[$key])) {
if (array_key_exists($key, $globalSettings)) {
$mergedSettings[$key] = $globalSettings[$key];
} elseif (array_key_exists($key, $scopeSettings)) {
$mergedSettings[$key] = $scopeSettings[$key];
} elseif (array_key_exists($key, $groupsSettings)) {
$mergedSettings[$key] = $groupsSettings[$key];
} else {
$mergedSettings[$key] = $defaultSettings[$key];
}
} else {
$mergedSettings[$key] = array_merge(isset($defaultSettings[$key]) ? $defaultSettings[$key] : array(), isset($groupsSettings[$key]) ? $groupsSettings[$key] : array(), isset($scopeSettings[$key]) ? $scopeSettings[$key] : array(), isset($globalSettings[$key]) ? $globalSettings[$key] : array());
}
}
} else {
$mergedSettings = array_merge($defaultSettings, $groupsSettings, $scopeSettings, $globalSettings);
}
if ($options & static::UNIQUE) {
$mergedSettings = array_values(array_unique($mergedSettings));
}
$this->container->setParameter("{$this->namespace}.{$scope}.{$id}", $mergedSettings);
}
}