Skip to content

OS-244 datafordeler address lookup#32

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

OS-244 datafordeler address lookup#32
stankut wants to merge 6 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed: bb7616b

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed: bb7616b

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed: bb7616b

/**
* {@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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed: bb7616b

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to os2web_datalookup, refactored:
bb7616b


$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') {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

$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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

$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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


$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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@stankut
Copy link
Copy Markdown
Contributor Author

stankut commented May 25, 2026

@jekuaitk
thanks for a review, made the changes, please have a look again

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