Skip to content

Commit c454be2

Browse files
committed
Conversion of DocumentType Array to Relation fix
1 parent 188295f commit c454be2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/AbraFlexi/RO.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,8 @@ public function fixRecordTypes(array $record, $evidence = null)
11101110
break;
11111111
case 'relation':
11121112
if (\is_array($record[$column])) {
1113+
$value = $record[$column][0];
11131114
if (\Ease\Functions::isAssoc($record[$column])) {
1114-
$value = $record[$column][0];
11151115

11161116
if (\is_array($value)) {
11171117
$valueFields = array_keys($value);
@@ -1135,10 +1135,19 @@ public function fixRecordTypes(array $record, $evidence = null)
11351135
);
11361136
}
11371137
} else { // ExtIDs
1138-
foreach ($record[$column] as $relPos => $rawRelation) {
1139-
[,$ext,$extId] = explode(':', $rawRelation);
1140-
$record[$column][$ext] = new Relation($rawRelation, $ext, $extId, $column.' '.$ext.':'.$extId );
1141-
unset($record[$column][$relPos]);
1138+
if(count($record[$column]) == 1) {
1139+
$record[$column] = new Relation(
1140+
\array_key_exists('kod', $value) ? $value['kod'] : $value['id'],
1141+
$record[$column][0]['typDoklK'],
1142+
$record[$column][0]['id'],
1143+
$record[$column][0]['typDoklK@showAs']
1144+
);
1145+
} else {
1146+
foreach ($record[$column] as $relPos => $rawRelation) {
1147+
[,$ext,$extId] = explode(':', $rawRelation);
1148+
$record[$column][$ext] = new Relation($rawRelation, $ext, $extId, $column.' '.$ext.':'.$extId );
1149+
unset($record[$column][$relPos]);
1150+
}
11421151
}
11431152
}
11441153
} else {

0 commit comments

Comments
 (0)