Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update methods to align with os2web_datalookup #139

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

- Updated `os2web/os2web_audit` version
- Updated `os2web/os2web_datalookup` version

## [3.16.2] 2024-10-31

- Applied coding standards
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
"http-interop/http-factory-guzzle": "^1.0.0",
"itk-dev/beskedfordeler-drupal": "^1.0",
"itk-dev/serviceplatformen": "^1.5",
"os2web/os2web_audit": "^0.1",
"os2web/os2web_datalookup": "^1.5",
"os2web/os2web_audit": "^0.1.1",
"os2web/os2web_datalookup": "^2.0",
"os2web/os2web_nemlogin": "^1.0",
"php-http/guzzle7-adapter": "^1.0",
"phpoffice/phpword": "^0.18.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\os2forms_dawa\Entity\DatafordelerMatrikula;
use Drupal\os2web_audit\Service\Logger;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupBase;
use GuzzleHttp\ClientInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand All @@ -30,9 +31,15 @@ class DatafordelerDataLookup extends DataLookupBase implements DatafordelerDataL
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ClientInterface $httpClient) {
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
ClientInterface $httpClient,
Logger $auditLogger,
) {
$this->httpClient = $httpClient;
parent::__construct($configuration, $plugin_id, $plugin_definition);
parent::__construct($configuration, $plugin_id, $plugin_definition, $auditLogger);
}

/**
Expand All @@ -44,6 +51,7 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_id,
$plugin_definition,
$container->get('http_client'),
$container->get('os2web_audit.logger'),
);
}

Expand Down Expand Up @@ -102,7 +110,7 @@ public function getMatrikulaEntries(string $matrikulaId) : array {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
public function defaultConfiguration(): array {
return [
'username' => '',
'password' => '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getMatrikulaAutocompletePath() {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
public function defaultConfiguration(): array {
return [
'address_autocomplete_path' => 'https://dawa.aws.dk/adresser/autocomplete',
'address_api_path' => 'https://dawa.aws.dk/adresser',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Drupal\os2web_datalookup\LookupResult\CompanyLookupResult;
use Drupal\os2web_datalookup\LookupResult\CprLookupResult;
use Drupal\os2web_datalookup\Plugin\DataLookupManager;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCompany;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCpr;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCompanyInterface;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCprInterface;
use Drupal\webform\WebformSubmissionInterface;
use ItkDev\Serviceplatformen\Service\SF1601\SF1601;
use ItkDev\Serviceplatformen\Service\SF1601\Serializer;
Expand Down Expand Up @@ -99,7 +99,7 @@ public function log($level, $message, array $context = []): void {
*/
public function lookupCpr(string $cpr): CprLookupResult {
$instance = $this->dataLookupManager->createDefaultInstanceByGroup('cpr_lookup');
if (!($instance instanceof DataLookupInterfaceCpr)) {
if (!($instance instanceof DataLookupCprInterface)) {
throw new RuntimeException('Cannot get CPR data lookup instance');
}
$lookupResult = $instance->lookup($cpr);
Expand All @@ -115,7 +115,7 @@ public function lookupCpr(string $cpr): CprLookupResult {
*/
public function lookupCvr(string $cvr): CompanyLookupResult {
$instance = $this->dataLookupManager->createDefaultInstanceByGroup('cvr_lookup');
if (!($instance instanceof DataLookupInterfaceCompany)) {
if (!($instance instanceof DataLookupCompanyInterface)) {
throw new RuntimeException('Cannot get CVR data lookup instance');
}
$lookupResult = $instance->lookup($cvr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use Drupal\os2forms_digital_post\Plugin\AdvancedQueue\JobType\SendDigitalPostSF1601;
use Drupal\os2forms_digital_post\Plugin\WebformHandler\WebformHandlerSF1601;
use Drupal\os2web_datalookup\Plugin\DataLookupManager;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCompany;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCpr;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCompanyInterface;
use Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCprInterface;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform\WebformSubmissionStorageInterface;
use ItkDev\Serviceplatformen\Service\SF1601\SF1601;
Expand Down Expand Up @@ -127,7 +127,7 @@ public function sendDigitalPost(WebformSubmissionInterface $submission, array $h

if (preg_match('/^\d{8}$/', $recipientIdentifier)) {
$instance = $this->dataLookupManager->createDefaultInstanceByGroup('cvr_lookup');
if (!($instance instanceof DataLookupInterfaceCompany)) {
if (!($instance instanceof DataLookupCompanyInterface)) {
throw new RuntimeException('Cannot get CVR data lookup instance');
}
$lookupResult = $instance->lookup($recipientIdentifier);
Expand All @@ -138,7 +138,7 @@ public function sendDigitalPost(WebformSubmissionInterface $submission, array $h
}
else {
$instance = $this->dataLookupManager->createDefaultInstanceByGroup('cpr_lookup');
if (!($instance instanceof DataLookupInterfaceCpr)) {
if (!($instance instanceof DataLookupCprInterface)) {
throw new RuntimeException('Cannot get CPR data lookup instance');
}
$lookupResult = $instance->lookup($recipientIdentifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function mitidChildrenSelectAjax(array &$form, FormStateInterface
/** @var \Drupal\os2web_datalookup\Plugin\DataLookupManager $os2web_datalookup_plugins */
$os2web_datalookup_plugins = \Drupal::service('plugin.manager.os2web_datalookup');

/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCpr $cprPlugin */
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCprInterface $cprPlugin */
$cprPlugin = $os2web_datalookup_plugins->createDefaultInstanceByGroup('cpr_lookup');

if ($cprPlugin->isReady()) {
Expand Down
6 changes: 3 additions & 3 deletions modules/os2forms_nemid/src/Service/FormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function lookupPersonData(FormStateInterface $form_state) {
}

if ($cpr) {
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCpr $cprPlugin */
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCprInterface $cprPlugin */
$cprPlugin = $this->dataLookManager->createDefaultInstanceByGroup('cpr_lookup');

if ($cprPlugin->isReady()) {
Expand Down Expand Up @@ -284,15 +284,15 @@ private function lookupCompanyData(FormStateInterface $form_state) {

// Performing the lookup.
if ($cvr) {
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCompany $cvrPlugin */
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCompanyInterface $cvrPlugin */
$cvrPlugin = $this->dataLookManager->createDefaultInstanceByGroup('cvr_lookup');

if ($cvrPlugin->isReady()) {
$companyResult = $cvrPlugin->lookup($cvr);
}
}
elseif ($pNumber) {
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCompany $pNumberPlugin */
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCompanyInterface $pNumberPlugin */
$pNumberPlugin = $this->dataLookManager->createDefaultInstanceByGroup('pnumber_lookup');

if ($pNumberPlugin->isReady()) {
Expand Down
Loading