/**
* @see Model\Object\ClassDefinition\Data::getDataFromEditmode
* @param string $containerData
* @param null|Model\Object\AbstractObject $object
* @param mixed $params
* @return string
*/
public function getDataFromEditmode($containerData, $object = null, $params = [])
{
$classificationStore = $this->getDataFromObjectParam($object);
if (!$classificationStore instanceof Object\Classificationstore) {
$classificationStore = new Object\Classificationstore();
}
$data = $containerData["data"];
$activeGroups = $containerData["activeGroups"];
$groupCollectionMapping = $containerData["groupCollectionMapping"];
$correctedMapping = [];
foreach ($groupCollectionMapping as $groupId => $collectionId) {
if ($activeGroups[$groupId]) {
$correctedMapping[$groupId] = $collectionId;
}
}
$classificationStore->setGroupCollectionMappings($correctedMapping);
if (is_array($data)) {
foreach ($data as $language => $groups) {
foreach ($groups as $groupId => $keys) {
foreach ($keys as $keyId => $value) {
$keyConfig = $this->getKeyConfiguration($keyId);
$dataDefinition = Object\Classificationstore\Service::getFieldDefinitionFromKeyConfig($keyConfig);
$dataFromEditMode = $dataDefinition->getDataFromEditmode($value);
$activeGroups[$groupId] = true;
$classificationStore->setLocalizedKeyValue($groupId, $keyId, $dataFromEditMode, $language);
}
}
}
}
$activeGroupIds = array_keys($activeGroups);
$classificationStore->setActiveGroups($activeGroups);
// cleanup
$existingGroupIds = $classificationStore->getGroupIdsWithData();
if (is_array($existingGroupIds)) {
foreach ($existingGroupIds as $existingGroupId) {
if (!in_array($existingGroupId, $activeGroupIds)) {
$classificationStore->removeGroupData($existingGroupId);
}
}
}
return $classificationStore;
}