Skip to content
Snippets Groups Projects
Commit b9ac604f authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #4100

Closes #4100

Merge request studip/studip!2950
parent 329ab7b0
No related branches found
No related tags found
No related merge requests found
......@@ -568,10 +568,11 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
$record_data = [];
$relation_data = [];
foreach ($data as $key => $value) {
if (is_array($value)) {
$relation_data[$key] = $value;
} else {
$temp = static::alias_fields()[$key] ?? $key;
if (isset(static::db_fields()[$temp])) {
$record_data[$key] = $value;
} else {
$relation_data[$key] = $value;
}
}
$record = static::toObject($record_data);
......@@ -581,8 +582,11 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
} else {
$record->setData($record_data);
}
if (is_array($relation_data)) {
foreach ($relation_data as $relation => $data) {
if (!$record->isRelation($relation)) {
continue;
}
$options = $record->getRelationOptions($relation);
if ($options['type'] == 'has_one') {
$record->{$relation} = call_user_func([$options['class_name'], 'import'], $data);
......@@ -607,7 +611,6 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
}
}
}
}
return $record;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment