Skip to content

Commit c4e3f4b

Browse files
authored
Merge pull request #10 from OS2web/f/OS2FORMS-359-cpr-lookup
OS2Forms-359 single child fix
2 parents 9021990 + 9cac753 commit c4e3f4b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
7373
}
7474

7575
/**
76-
* @inheritDoc
76+
* {@inheritDoc}
7777
*/
7878
public function lookup($cpr, $allowCprTestModeReplace = TRUE) {
7979
if ($this->configuration['mode_selector'] == 1 && $this->configuration['test_mode_fixed_cpr']) {
@@ -115,8 +115,13 @@ public function lookup($cpr, $allowCprTestModeReplace = TRUE) {
115115
}
116116

117117
$relationship = $result['relationer'];
118-
if (isset($relationship->barn) && is_array($relationship->barn)) {
119-
$children = [];
118+
119+
$children = [];
120+
if (isset($relationship->barn)) {
121+
if (!is_array($relationship->barn)) {
122+
$relationship->barn = [$relationship->barn];
123+
}
124+
120125
foreach ($relationship->barn as $child) {
121126
$childCprResult = $this->lookup($child->personnummer, FALSE);
122127

@@ -125,8 +130,8 @@ public function lookup($cpr, $allowCprTestModeReplace = TRUE) {
125130
'name' => $childCprResult->getName(),
126131
];
127132
}
128-
$cprResult->setChildren($children);
129133
}
134+
$cprResult->setChildren($children);
130135

131136
// Leaving empty, no information in webservice.
132137
$cprResult->setCoName('');

0 commit comments

Comments
 (0)