Skip to content

Commit dccbcf0

Browse files
author
Stanislav Kutasevits
committed
S2FRMS-40 - Adding Children name address protection
1 parent 55eff49 commit dccbcf0

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/LookupResult/CprLookupResult.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class CprLookupResult {
112112
*
113113
* @var bool
114114
*/
115-
protected $nameAddressProtected;
115+
protected $nameAddressProtected = FALSE;
116116

117117
/**
118118
* Array of children.
@@ -385,6 +385,7 @@ public function getChildren(): array {
385385
* 0 => [
386386
* 'cpr' => xxxxx,
387387
* 'name' => full name,
388+
* 'nameAddressProtected' => TRUE/FALSE
388389
* ],
389390
* ...
390391
* ]
@@ -402,6 +403,7 @@ public function setChildren(array $children): void {
402403
* 0 => [
403404
* 'cpr' => xxxxx,
404405
* 'type' => type of guardian,
406+
* 'nameAddressProtected' => TRUE/FALSE
405407
* ],
406408
* ...
407409
* ]

src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ public function lookup($cpr, $fetchChildren = TRUE, $allowCprTestModeReplace = T
164164
$cprResult->setDigitalPostSubscribed(TRUE);
165165
}
166166

167+
if ($persondata->adressebeskyttelse) {
168+
if ($persondata->adressebeskyttelse->beskyttet) {
169+
$cprResult->setNameAddressProtected(TRUE);
170+
}
171+
}
172+
167173
$address = $result['adresse'];
168174
if ($address->aktuelAdresse) {
169175
$cprResult->setStreet($address->aktuelAdresse->vejnavn ?? '');
@@ -205,11 +211,12 @@ public function lookup($cpr, $fetchChildren = TRUE, $allowCprTestModeReplace = T
205211
$childCprResult = $this->lookup($relationshipChild->personnummer, FALSE, FALSE);
206212

207213
if ($childCprResult->isSuccessful() && $childCprResult->hasGuardian($cpr)) {
208-
$child['name'] = $childCprResult->getName();
214+
$child['name'] = $childCprResult->getName() ?? $childCprResult->getCpr();
209215

210216
$child = [
211217
'cpr' => $relationshipChild->personnummer,
212-
'name' => $child['name']
218+
'name' => $child['name'],
219+
'nameAddressProtected' => $childCprResult->isNameAddressProtected(),
213220
];
214221

215222
$children[] = $child;
@@ -257,7 +264,6 @@ public function lookup($cpr, $fetchChildren = TRUE, $allowCprTestModeReplace = T
257264

258265
// Leaving empty, no information in webservice.
259266
$cprResult->setCoName('');
260-
$cprResult->setNameAddressProtected(FALSE);
261267
}
262268
else {
263269
$cprResult->setSuccessful(FALSE);

0 commit comments

Comments
 (0)