Skip to content

Commit

Permalink
OS2Forms-359 single child fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stankut committed May 23, 2023
1 parent 9021990 commit 9cac753
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function lookup($cpr, $allowCprTestModeReplace = TRUE) {
if ($this->configuration['mode_selector'] == 1 && $this->configuration['test_mode_fixed_cpr']) {
Expand Down Expand Up @@ -115,8 +115,13 @@ public function lookup($cpr, $allowCprTestModeReplace = TRUE) {
}

$relationship = $result['relationer'];
if (isset($relationship->barn) && is_array($relationship->barn)) {
$children = [];

$children = [];
if (isset($relationship->barn)) {
if (!is_array($relationship->barn)) {
$relationship->barn = [$relationship->barn];
}

foreach ($relationship->barn as $child) {
$childCprResult = $this->lookup($child->personnummer, FALSE);

Expand All @@ -125,8 +130,8 @@ public function lookup($cpr, $allowCprTestModeReplace = TRUE) {
'name' => $childCprResult->getName(),
];
}
$cprResult->setChildren($children);
}
$cprResult->setChildren($children);

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

0 comments on commit 9cac753

Please sign in to comment.