Skip to content

Commit

Permalink
Avoiding TypeError or wrong CPR code of the child
Browse files Browse the repository at this point in the history
  • Loading branch information
stankut committed May 25, 2023
1 parent 9cac753 commit e5c06ce
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,20 @@ public function lookup($cpr, $allowCprTestModeReplace = TRUE) {
$relationship->barn = [$relationship->barn];
}

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

$children[] = [
'cpr' => $childCprResult->getCpr(),
'name' => $childCprResult->getName(),
foreach ($relationship->barn as $relationshipChild) {
// Sometimes CPR lookup can return no results, creating child without
// name.
$child = [
'cpr' => $relationshipChild->personnummer,
'name' => '',
];

$childCprResult = $this->lookup($relationshipChild->personnummer, FALSE);
if ($childCprResult->isSuccessful()) {
$child['name'] = $childCprResult->getName();
}

$children[] = $child;
}
}
$cprResult->setChildren($children);
Expand Down

0 comments on commit e5c06ce

Please sign in to comment.