Skip to content

OS-244 datafordeler address lookup#32

Open
stankut wants to merge 3 commits into
mainfrom
f/datafordeler_address
Open

OS-244 datafordeler address lookup#32
stankut wants to merge 3 commits into
mainfrom
f/datafordeler_address

Conversation

@stankut
Copy link
Copy Markdown
Contributor

@stankut stankut commented May 15, 2026

Link to ticket

OS2Forms/os2forms#246

Description

Introducing Datafordeler Address lookup.

namespace Drupal\os2web_datalookup\LookupResult;

/**
* Representation or value object for the result of a CPR lookup.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Representation or value object for the result of a CPR lookup.
* Representation or value object for the result of an address lookup.

protected string $fullAddress;

/**
* Street of the person.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Street of the person.
* Street.

Or something similar

protected $accessAddressId;

/**
* Name of the person.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Name of the person.
* Full address.

/**
* {@inheritdoc}
*/
public function getSingleAddress(ParameterBag $params) : AddressLookupResult {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be able to return NULL.

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\key\KeyRepositoryInterface;
use Drupal\os2forms_dawa\Entity\DatafordelerMatrikula;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a os2forms_dawa dependency? Or should the entity perhaps be moved to this module? It seems strange for this in essence non-forms module to have a strict dependency on os2forms_dawa.


$jsonDecoded = json_decode($json, TRUE);
if (is_array($jsonDecoded) && !empty($jsonDecoded)) {
if ($jsonDecoded['status'] == 'ok') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($jsonDecoded['status'] == 'ok') {
if ($jsonDecoded['status'] === 'ok') {

$token = $this->getConfiguration()['token'];
$url = "https://adressevaelger.dk/adresser/soeg";

$json = '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest removing this and simply return the empty array in catch beneath if the request fails.

$address = new AddressLookupResult();
$address->setSuccessful(FALSE);

$json = '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove and return $address in the catch

public function getMatrikulaId(string $addressAccessId) : ?string {
$url = "https://services.datafordeler.dk/DAR/DAR/3.0.0/rest/husnummerTilJordstykke";

$json = '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo, remove and return early in catch


$configuration = $this->getConfiguration();

$json = '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, remove and return early in catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAWA (Danmarks Adressers Web API) lukker ned pr. 1. juli 2026

2 participants