protected function resolveAliases($data, $currentPath)
{
if (!is_array($data)) {
return $data;
}
foreach ($data as $nodeString => $nodeChildren) {
if (self::getNodeName($nodeString) === 'alias') {
if (self::getAttributeValue($nodeString, 'source') !== 'locale') {
// Value of source attribute can be 'locale' or particular locale identifier, but we do not support the second mode, ignore it silently
break;
}
$sourcePath = self::getAttributeValue($nodeString, 'path');
// Change relative path to absolute one
$sourcePath = str_replace('../', '', $sourcePath, $countOfJumpsToParentNode);
$sourcePath = str_replace('\'', '"', $sourcePath);
$currentPathNodeNames = explode('/', $currentPath);
for ($i = 0; $i < $countOfJumpsToParentNode; ++$i) {
unset($currentPathNodeNames[count($currentPathNodeNames) - 1]);
}
$sourcePath = implode('/', $currentPathNodeNames) . '/' . $sourcePath;
unset($data[$nodeString]);
$sourceData = $this->getRawData($sourcePath);
if (is_array($sourceData)) {
$data = array_merge($sourceData, $data);
}
break;
} else {
$data[$nodeString] = $this->resolveAliases($data[$nodeString], $currentPath === '' ? $nodeString : $currentPath . '/' . $nodeString);
}
}
return $data;
}