From ae8cb5aa53b24f94aa1643ea8135a9b4dcbd8bb1 Mon Sep 17 00:00:00 2001 From: Stanislav Kutasevits Date: Thu, 1 Jun 2023 11:27:57 +0300 Subject: [PATCH] OS-53 CPR full address --- .../ServiceplatformenCPRExtended.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php b/src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php index bfd91c9..3c20f03 100644 --- a/src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php +++ b/src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php @@ -111,7 +111,23 @@ public function lookup($cpr, $allowCprTestModeReplace = TRUE) { $cprResult->setPostalCode($address->aktuelAdresse->postnummer ?? ''); $cprResult->setCity($address->aktuelAdresse->postdistrikt ?? ''); $cprResult->setMunicipalityCode($address->aktuelAdresse->kommunekode ?? ''); - $cprResult->setAddress($address->aktuelAdresse->standardadresse ?? ''); + + // Composing full address in one line. + $address = $cprResult->getStreet(); + if ($cprResult->getHouseNr()) { + $address .= ' ' . $cprResult->getHouseNr(); + } + if ($cprResult->getFloor()) { + $address .= ' ' . $cprResult->getFloor(); + } + if ($cprResult->getApartmentNr()) { + $address .= ' ' . $cprResult->getApartmentNr(); + } + if ($cprResult->getPostalCode() && $cprResult->getCity()) { + $address .= ', ' . $cprResult->getPostalCode() . ' ' . $cprResult->getCity(); + } + + $cprResult->setAddress($address ?? ''); } $relationship = $result['relationer'];