From 716633577615040f024d395040c03a282f4bc009 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 1 May 2024 09:13:38 +0200 Subject: [PATCH 1/8] Added support for os2web_key # Conflicts: # src/Plugin/os2web/DataLookup/DataLookupBase.php # src/Plugin/os2web/DataLookup/DatafordelerBase.php # src/Plugin/os2web/DataLookup/DatafordelerCVR.php # src/Plugin/os2web/DataLookup/DatafordelerPNumber.php # src/Plugin/os2web/DataLookup/ServiceplatformenBase.php # src/Plugin/os2web/DataLookup/ServiceplatformenCPR.php # src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php --- .gitignore | 2 + composer.json | 7 +- src/Exception/RuntimeException.php | 8 + .../os2web/DataLookup/DataLookupBase.php | 88 ++++++++++- .../os2web/DataLookup/DatafordelerBase.php | 88 ++++++++++- .../os2web/DataLookup/DatafordelerCVR.php | 6 +- .../os2web/DataLookup/DatafordelerPNumber.php | 6 +- .../DataLookup/ServiceplatformenBase.php | 139 ++++++++++++++---- 8 files changed, 296 insertions(+), 48 deletions(-) create mode 100644 .gitignore create mode 100644 src/Exception/RuntimeException.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d8a7996 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/ diff --git a/composer.json b/composer.json index aa34269..a709af9 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,14 @@ "prefer-stable": true, "license": "EUPL-1.2", "require": { - "ext-soap": "*" + "ext-soap": "*", + "os2web/os2web_key": "dev-os2web_key" }, "repositories": { + "os2web/os2web_key": { + "type": "vcs", + "url": "https://github.com/rimi-itk/os2web_key" + }, "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php new file mode 100644 index 0000000..f1b163c --- /dev/null +++ b/src/Exception/RuntimeException.php @@ -0,0 +1,8 @@ +auditLogger = $auditLogger; $this->setConfiguration($configuration); + $this->init(); + } + + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) + { + /** @var KeyRepositoryInterface $keyRepository */ + $keyRepository = $container->get('key.repository'); + /** @var FileSystem $fileSystem */ + $fileSystem = $container->get('file_system'); + + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $keyRepository, + $fileSystem + ); } /** + * Plugin init method. + */ + protected function init() + { + } + + /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { @@ -86,8 +127,11 @@ public function setConfiguration(array $configuration): static { /** * {@inheritdoc} */ - public function defaultConfiguration(): array { - return []; + public function defaultConfiguration() { + return [ + 'certificate_provider' => '', + 'certificate_key' => '', + ]; } /** @@ -118,4 +162,44 @@ public function isReady(): bool { return $this->isReady; } + /** + * Get certificate. + */ + protected function getCertificate(): string { + return ''; + } + + /** + * Create a temporary file path for a certificate. + * + * Note: We do not want the create a file. Just get a temporary file name. + * + * @return string + * The local certificate path. + */ + protected function createLocalCertPath(): string { + $this->localCertPath = $this->fileSystem->getTempDirectory().'/'.uniqid('os2web_datalookup_local_cert_'); + + return $this->localCertPath; + } + + /** + * Write certificate to temporary certificate file. + * + * @return string + * The local certificate path. + */ + protected function writeCertificateToFile(): string + { + // Write certificate to local_cert location. + $certificate = $this->getCertificate(); + $localCertPath = $this->localCertPath; + $result = $this->fileSystem->saveData($certificate, $localCertPath, FileSystem::EXISTS_REPLACE); + if (!$result) { + return new RuntimeException(sprintf('Error writing certificate to temporary file %s', $localCertPath)); + } + + return $result; + } + } diff --git a/src/Plugin/os2web/DataLookup/DatafordelerBase.php b/src/Plugin/os2web/DataLookup/DatafordelerBase.php index 9c3179a..c156cdb 100644 --- a/src/Plugin/os2web/DataLookup/DatafordelerBase.php +++ b/src/Plugin/os2web/DataLookup/DatafordelerBase.php @@ -2,9 +2,12 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; +use Drupal\Core\File\FileSystem; use Drupal\Core\Form\FormStateInterface; +use Drupal\os2web_datalookup\Exception\RuntimeException; use Drupal\os2web_audit\Service\Logger; use GuzzleHttp\Client; +use Psr\Http\Message\ResponseInterface; /** * Defines base plugin class for Datafordeler lookup plugins. @@ -32,7 +35,7 @@ public function __construct( } /** - * Plugin init method. + * {@inheritdoc} */ private function init(): void { $this->isReady = FALSE; @@ -46,8 +49,10 @@ private function init(): void { 'accept' => 'application/json', ], ]; - if ($certPath = $configuration['cert_path_live']) { - $options['cert'] = $certPath; + + if (isset($configuration['cert_path_live']) || isset($configuration['key'])) { + $options['cert'] = $this->createLocalCertPath(); + $this->httpClient = new Client($options); $this->isReady = TRUE; } @@ -77,18 +82,53 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#default_value' => $this->configuration['webserviceurl_live'], ]; - $form['cert_path_live'] = [ + $form['certificate'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Certificate'), + + 'certificate_provider' => [ + '#type' => 'select', + '#title' => $this->t('Provider'), + '#options' => [ + self::PROVIDER_TYPE_FORM => $this->t('Form'), + self::PROVIDER_TYPE_KEY => $this->t('Key'), + ], + '#default_value' => $this->configuration['certificate_provider'] ?? self::PROVIDER_TYPE_FORM, + ], + + 'certificate_key' => [ + '#type' => 'key_select', + '#key_filters' => [ + 'type' => 'os2web_certificate', + ], + '#title' => $this->t('Key'), + '#default_value' => $this->configuration['certificate_key'] ?? NULL, + '#states' => [ + 'required' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_KEY]], + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_KEY]], + ], + ], + + 'cert_path_live' => [ '#type' => 'textfield', '#title' => $this->t('Certificate (LIVE)'), '#description' => $this->t('Path to the certificate'), '#default_value' => $this->configuration['cert_path_live'], - ]; + '#states' => [ + 'required' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + ], + ], - $form['cert_passphrase_live'] = [ + 'cert_passphrase_live' => [ '#type' => 'password', '#title' => $this->t('Certificate passphrase (LIVE)'), '#description' => $this->t('leave empty if not used'), '#default_value' => $this->configuration['cert_passphrase_live'], + '#states' => [ + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + ], + ], ]; return $form; @@ -110,4 +150,40 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s $this->setConfiguration($configuration); } + /** + * Get response. + */ + protected function getResponse(string $uri, array $options): ResponseInterface + { + try { + $localCertPath = $this->writeCertificateToFile(); + + return $this->httpClient->get($uri, $options); + } finally { + // Remove temporary certificate file. + if (file_exists($localCertPath)) { + unlink($localCertPath); + } + } + } + + /** + * Get certificate. + */ + protected function getCertificate(): string { + $provider = $this->configuration['certificate_provider'] ?? NULL; + if (self::PROVIDER_TYPE_KEY === $provider) { + $keyId = $this->configuration['certificate_key'] ?? ''; + $key = $this->keyRepository->getKey($keyId); + if (NULL === $key) { + throw new RuntimeException(sprintf('Cannot get key %s', $keyId)); + } + + return $key->getKeyValue(); + } + + $filename = $this->configuration['cert_path_live']; + + return file_get_contents($filename); + } } diff --git a/src/Plugin/os2web/DataLookup/DatafordelerCVR.php b/src/Plugin/os2web/DataLookup/DatafordelerCVR.php index 8dfac53..9c136a7 100644 --- a/src/Plugin/os2web/DataLookup/DatafordelerCVR.php +++ b/src/Plugin/os2web/DataLookup/DatafordelerCVR.php @@ -24,10 +24,8 @@ class DatafordelerCVR extends DatafordelerBase implements DataLookupCompanyInter */ public function defaultConfiguration(): array { return [ - 'webserviceurl_live' => 'https://s5-certservices.datafordeler.dk/CVR/HentCVRData/1/REST/', - 'cert_path_live' => '', - 'cert_passphrase_live' => '', - ]; + 'webserviceurl_live' => 'https://s5-certservices.datafordeler.dk/CVR/HentCVRData/1/REST/', + ] + parent::defaultConfiguration(); } /** diff --git a/src/Plugin/os2web/DataLookup/DatafordelerPNumber.php b/src/Plugin/os2web/DataLookup/DatafordelerPNumber.php index 14ac1ba..08c8c6c 100644 --- a/src/Plugin/os2web/DataLookup/DatafordelerPNumber.php +++ b/src/Plugin/os2web/DataLookup/DatafordelerPNumber.php @@ -24,10 +24,8 @@ class DatafordelerPNumber extends DatafordelerBase implements DataLookupCompanyI */ public function defaultConfiguration(): array { return [ - 'webserviceurl_live' => 'https://s5-certservices.datafordeler.dk/CVR/HentCVRData/1/REST/', - 'cert_path_live' => '', - 'cert_passphrase_live' => '', - ]; + 'webserviceurl_live' => 'https://s5-certservices.datafordeler.dk/CVR/HentCVRData/1/REST/', + ] + parent::defaultConfiguration(); } /** diff --git a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php index a888d73..ccf5229 100644 --- a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php +++ b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php @@ -2,7 +2,10 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; +use Drupal\Core\File\FileSystem; use Drupal\Core\Form\FormStateInterface; +use Drupal\key\KeyRepositoryInterface; +use Drupal\os2web_datalookup\Exception\RuntimeException; use Drupal\os2web_audit\Service\Logger; /** @@ -42,19 +45,19 @@ public function __construct( */ public function defaultConfiguration(): array { return [ - 'mode_selector' => 0, - 'serviceagreementuuid' => '', - 'serviceuuid' => '', - 'wsdl' => '', - 'location' => '', - 'location_test' => '', - 'usersystemuuid' => '', - 'useruuid' => '', - 'accountinginfo' => '', - 'certfile_passphrase' => '', - 'certfile' => '', - 'certfile_test' => '', - ]; + 'mode_selector' => 0, + 'serviceagreementuuid' => '', + 'serviceuuid' => '', + 'wsdl' => '', + 'location' => '', + 'location_test' => '', + 'usersystemuuid' => '', + 'useruuid' => '', + 'accountinginfo' => '', + 'certfile_passphrase' => '', + 'certfile' => '', + 'certfile_test' => '', + ] + parent::defaultConfiguration(); } /** @@ -125,22 +128,61 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#default_value' => $this->configuration['accountinginfo'], ]; - $form['certfile_passphrase'] = [ - '#type' => 'password', - '#title' => 'Certfile passphrase', - '#default_value' => $this->configuration['certfile_passphrase'], - ]; + $form['certificate'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Certificate'), + + 'certificate_provider' => [ + '#type' => 'select', + '#title' => $this->t('Provider'), + '#options' => [ + self::PROVIDER_TYPE_FORM => $this->t('Form'), + self::PROVIDER_TYPE_KEY => $this->t('Key'), + ], + '#default_value' => $this->configuration['certificate_provider'] ?? self::PROVIDER_TYPE_FORM, + ], - $form['certfile'] = [ - '#type' => 'textfield', - '#title' => 'Certfile (live)', - '#default_value' => $this->configuration['certfile'], - ]; + 'certificate_key' => [ + '#type' => 'key_select', + '#key_filters' => [ + 'type' => 'os2web_certificate', + ], + '#title' => $this->t('Key'), + '#default_value' => $this->configuration['certificate_key'] ?? NULL, + '#states' => [ + 'required' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_KEY]], + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_KEY]], + ], + ], - $form['certfile_test'] = [ - '#type' => 'textfield', - '#title' => 'Certfile (test)', - '#default_value' => $this->configuration['certfile_test'], + 'certfile_passphrase' => [ + '#type' => 'password', + '#title' => 'Certfile passphrase', + '#default_value' => $this->configuration['certfile_passphrase'], + '#states' => [ + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + ], + ], + + 'certfile' => [ + '#type' => 'textfield', + '#title' => 'Certfile (live)', + '#default_value' => $this->configuration['certfile'], + '#states' => [ + 'required' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + ], + ], + + 'certfile_test' => [ + '#type' => 'textfield', + '#title' => 'Certfile (test)', + '#default_value' => $this->configuration['certfile_test'], + '#states' => [ + 'required' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + ], + ], ]; return $form; @@ -170,7 +212,7 @@ public function getStatus(): string { } /** - * Plugin init method. + * {@inheritdoc} */ private function init(): void { ini_set('soap.wsdl_cache_enabled', 0); @@ -209,13 +251,19 @@ private function init(): void { } } + $provider = $this->configuration['certificate_provider'] ?? NULL; + $passphrase = self::PROVIDER_TYPE_KEY === $provider + // The certificate provider provides a passwordless certificate. + ? '' + : ($this->configuration['certfile_passphrase'] ?? ''); + try { switch ($this->configuration['mode_selector']) { case 0: $ws_config = [ 'location' => $this->configuration['location'], - 'local_cert' => $this->configuration['certfile'], - 'passphrase' => $this->configuration['certfile_passphrase'], + 'local_cert' => $this->createLocalCertPath(), + 'passphrase' => $passphrase, 'trace' => TRUE, ]; break; @@ -223,7 +271,8 @@ private function init(): void { case 1: $ws_config = [ 'location' => $this->configuration['location_test'], - 'local_cert' => $this->configuration['certfile_test'], + 'local_cert' => $this->createLocalCertPath(), + 'passphrase' => $passphrase, 'trace' => TRUE, ]; break; @@ -309,6 +358,7 @@ protected function query(string $method, array $request): array { } try { + $localCertPath = $this->writeCertificateToFile(); $msg = sprintf('Method %s called with (%s)', $method, $auditLoggingMethodParameter); $this->auditLogger->info('DataLookup', $msg); $response = (array) $this->client->$method($request); @@ -321,9 +371,36 @@ protected function query(string $method, array $request): array { 'status' => FALSE, 'error' => $e->faultstring, ]; + } finally { + // Remove temporary certificate file. + if (file_exists($localCertPath)) { + unlink($localCertPath); + } } return $response; } + /** + * Get certificate. + */ + protected function getCertificate(): string { + $provider = $this->configuration['certificate_provider'] ?? NULL; + if (self::PROVIDER_TYPE_KEY === $provider) { + $keyId = $this->configuration['certificate_key'] ?? ''; + $key = $this->keyRepository->getKey($keyId); + if (NULL === $key) { + throw new RuntimeException(sprintf('Cannot get key %s', $keyId)); + } + + return $key->getKeyValue(); + } + + $filename = 0 === $this->configuration['mode_selector'] + ? $this->configuration['certfile'] + : $this->configuration['certfile_test']; + + return file_get_contents($filename); + } + } From a596be1df5a3d7092f152363033342643de19214 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 1 May 2024 12:49:43 +0200 Subject: [PATCH 2/8] Defined coding standards and applied in select places --- .markdownlintrc | 19 ++++++++ README.md | 36 +++++++++++++- composer.json | 1 - phpstan.neon | 13 +++++ scripts/code-analysis | 47 +++++++++++++++++++ src/Exception/RuntimeException.php | 6 ++- .../os2web/DataLookup/DataLookupBase.php | 24 +++++----- .../os2web/DataLookup/DatafordelerBase.php | 41 ++++++++-------- .../os2web/DataLookup/DatafordelerCVR.php | 4 +- .../os2web/DataLookup/DatafordelerPNumber.php | 4 +- .../DataLookup/ServiceplatformenBase.php | 28 +++++------ 11 files changed, 167 insertions(+), 56 deletions(-) create mode 100644 .markdownlintrc create mode 100644 phpstan.neon create mode 100755 scripts/code-analysis diff --git a/.markdownlintrc b/.markdownlintrc new file mode 100644 index 0000000..be08e16 --- /dev/null +++ b/.markdownlintrc @@ -0,0 +1,19 @@ +{ + // @see https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc + // https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md + "MD013": { + // Exclude code blocks + "code_blocks": false, + "line_length": 120 + }, + + // Prevent complaining on duplicated headings in CHANGELOG.md + // https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md + "MD024": { + "siblings_only": true + } +} + +// Local Variables: +// mode: json +// End: diff --git a/README.md b/README.md index a84bb1a..2280234 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ if ($cprPlugin->isReady()) { ## New services/features -### Datafordeler integration (https://datafordeler.dk) +### Datafordeler integration () In the scope of os2forms project already implemented light integration with Danmarks Adresseregister (DAR) via fetching data for form elements autocomplete. @@ -98,3 +98,37 @@ will be exposed for third persons. To avoid/prevent this behavior, we recommend use `Config ignore` module, where you can add all settings you do not want to export/import via the configuration management system. + +## Coding standards + +Our coding are checked by GitHub Actions (cf. +[.github/workflows/pr.yml](.github/workflows/pr.yml)). Use the commands below to +run the checks locally. + +### PHP + +```shell +docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer install +# Fix (some) coding standards issues +docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-apply +# Check that code adheres to the coding standards +docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-check +``` + +### Markdown + +```shell +docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md' --fix +docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md' +``` + +## Code analysis + +We use [PHPStan](https://phpstan.org/) for static code analysis. + +Running statis code analysis on a standalone Drupal module is a bit tricky, so we use a helper script to run the +analysis: + +```shell +docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm ./scripts/code-analysis +``` diff --git a/composer.json b/composer.json index a709af9..2151e58 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,6 @@ "prefer-stable": true, "license": "EUPL-1.2", "require": { - "ext-soap": "*", "os2web/os2web_key": "dev-os2web_key" }, "repositories": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..e51b69f --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,13 @@ +parameters: + level: 6 + paths: + - src + + ignoreErrors: + - "#Method [a-zA-Z0-9\\_\\\\:\\(\\)]+ has parameter \\$[a-zA-Z0-9_]+ with no value type specified in iterable type array#" + - "#Method [a-zA-Z0-9\\_\\\\:\\(\\)]+ return type has no value type specified in iterable type array#" + - '#Unsafe usage of new static\(\).#' + +# Local Variables: +# mode: yaml +# End: diff --git a/scripts/code-analysis b/scripts/code-analysis new file mode 100755 index 0000000..73ec750 --- /dev/null +++ b/scripts/code-analysis @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +script_dir=$(pwd) +module_name=$(basename "$script_dir") +drupal_dir=vendor/drupal-module-code-analysis +# Relative to $drupal_dir +module_path=web/modules/contrib/$module_name + +cd "$script_dir" || exit + +drupal_composer() { + composer --working-dir="$drupal_dir" --no-interaction "$@" +} + +# # Create new Drupal 9 project +# if [ ! -f "$drupal_dir/composer.json" ]; then +# composer --no-interaction create-project drupal/recommended-project:^9 "$drupal_dir" +# fi +# # Copy our code into the modules folder + +# # Clean up +# rm -fr "${drupal_dir:?}/$module_path" + +# # https://stackoverflow.com/a/15373763 +# # rsync --archive --compress . --filter=':- .gitignore' --exclude "$drupal_dir" --exclude .git "$drupal_dir/$module_path" + +# # The rsync command in not available in itkdev/php8.1-fpm + +# git config --global --add safe.directory /app +# # Copy module files into module path +# for f in $(git ls-files); do +# mkdir -p "$drupal_dir/$module_path/$(dirname "$f")" +# cp "$f" "$drupal_dir/$module_path/$f" +# done + +# drupal_composer config minimum-stability dev + +# # Allow ALL plugins +# # https://getcomposer.org/doc/06-config.md#allow-plugins +# drupal_composer config --no-plugins allow-plugins true + +# drupal_composer require wikimedia/composer-merge-plugin +# drupal_composer config extra.merge-plugin.include "$module_path/composer.json" +# # https://www.drupal.org/project/drupal/issues/3220043#comment-14845434 +# drupal_composer require --dev symfony/phpunit-bridge + +# Run PHPStan +(cd "$drupal_dir" && vendor/bin/phpstan --configuration="$module_path/phpstan.neon") diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php index f1b163c..0dd1e03 100644 --- a/src/Exception/RuntimeException.php +++ b/src/Exception/RuntimeException.php @@ -2,7 +2,9 @@ namespace Drupal\os2web_datalookup\Exception; -class RuntimeException extends \RuntimeException -{ +/** + * + */ +class RuntimeException extends \RuntimeException { } diff --git a/src/Plugin/os2web/DataLookup/DataLookupBase.php b/src/Plugin/os2web/DataLookup/DataLookupBase.php index 9c8cf6a..a55c6fe 100644 --- a/src/Plugin/os2web/DataLookup/DataLookupBase.php +++ b/src/Plugin/os2web/DataLookup/DataLookupBase.php @@ -58,7 +58,7 @@ public function __construct( $plugin_definition, Logger $auditLogger, protected KeyRepositoryInterface $keyRepository, - protected FileSystem $fileSystem + protected FileSystem $fileSystem, ) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->auditLogger = $auditLogger; @@ -66,11 +66,13 @@ public function __construct( $this->init(); } - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) - { - /** @var KeyRepositoryInterface $keyRepository */ + /** + * + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + /** @var \Drupal\key\KeyRepositoryInterface $keyRepository */ $keyRepository = $container->get('key.repository'); - /** @var FileSystem $fileSystem */ + /** @var \Drupal\Core\File\FileSystem $fileSystem */ $fileSystem = $container->get('file_system'); return new static( @@ -85,11 +87,10 @@ public static function create(ContainerInterface $container, array $configuratio /** * Plugin init method. */ - protected function init() - { + protected function init() { } - /** + /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { @@ -178,7 +179,7 @@ protected function getCertificate(): string { * The local certificate path. */ protected function createLocalCertPath(): string { - $this->localCertPath = $this->fileSystem->getTempDirectory().'/'.uniqid('os2web_datalookup_local_cert_'); + $this->localCertPath = $this->fileSystem->getTempDirectory() . '/' . uniqid('os2web_datalookup_local_cert_'); return $this->localCertPath; } @@ -187,10 +188,9 @@ protected function createLocalCertPath(): string { * Write certificate to temporary certificate file. * * @return string - * The local certificate path. + * The local certificate path. */ - protected function writeCertificateToFile(): string - { + protected function writeCertificateToFile(): string { // Write certificate to local_cert location. $certificate = $this->getCertificate(); $localCertPath = $this->localCertPath; diff --git a/src/Plugin/os2web/DataLookup/DatafordelerBase.php b/src/Plugin/os2web/DataLookup/DatafordelerBase.php index c156cdb..b5667aa 100644 --- a/src/Plugin/os2web/DataLookup/DatafordelerBase.php +++ b/src/Plugin/os2web/DataLookup/DatafordelerBase.php @@ -2,7 +2,6 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; -use Drupal\Core\File\FileSystem; use Drupal\Core\Form\FormStateInterface; use Drupal\os2web_datalookup\Exception\RuntimeException; use Drupal\os2web_audit\Service\Logger; @@ -109,25 +108,25 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta ], ], - 'cert_path_live' => [ - '#type' => 'textfield', - '#title' => $this->t('Certificate (LIVE)'), - '#description' => $this->t('Path to the certificate'), - '#default_value' => $this->configuration['cert_path_live'], - '#states' => [ - 'required' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], - 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], - ], - ], - - 'cert_passphrase_live' => [ - '#type' => 'password', - '#title' => $this->t('Certificate passphrase (LIVE)'), - '#description' => $this->t('leave empty if not used'), - '#default_value' => $this->configuration['cert_passphrase_live'], - '#states' => [ - 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + 'cert_path_live' => [ + '#type' => 'textfield', + '#title' => $this->t('Certificate (LIVE)'), + '#description' => $this->t('Path to the certificate'), + '#default_value' => $this->configuration['cert_path_live'], + '#states' => [ + 'required' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + ], ], + + 'cert_passphrase_live' => [ + '#type' => 'password', + '#title' => $this->t('Certificate passphrase (LIVE)'), + '#description' => $this->t('leave empty if not used'), + '#default_value' => $this->configuration['cert_passphrase_live'], + '#states' => [ + 'visible' => [':input[name="certificate_provider"]' => ['value' => self::PROVIDER_TYPE_FORM]], + ], ], ]; @@ -153,8 +152,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s /** * Get response. */ - protected function getResponse(string $uri, array $options): ResponseInterface - { + protected function getResponse(string $uri, array $options): ResponseInterface { try { $localCertPath = $this->writeCertificateToFile(); @@ -186,4 +184,5 @@ protected function getCertificate(): string { return file_get_contents($filename); } + } diff --git a/src/Plugin/os2web/DataLookup/DatafordelerCVR.php b/src/Plugin/os2web/DataLookup/DatafordelerCVR.php index 9c136a7..3477e16 100644 --- a/src/Plugin/os2web/DataLookup/DatafordelerCVR.php +++ b/src/Plugin/os2web/DataLookup/DatafordelerCVR.php @@ -24,8 +24,8 @@ class DatafordelerCVR extends DatafordelerBase implements DataLookupCompanyInter */ public function defaultConfiguration(): array { return [ - 'webserviceurl_live' => 'https://s5-certservices.datafordeler.dk/CVR/HentCVRData/1/REST/', - ] + parent::defaultConfiguration(); + 'webserviceurl_live' => 'https://s5-certservices.datafordeler.dk/CVR/HentCVRData/1/REST/', + ] + parent::defaultConfiguration(); } /** diff --git a/src/Plugin/os2web/DataLookup/DatafordelerPNumber.php b/src/Plugin/os2web/DataLookup/DatafordelerPNumber.php index 08c8c6c..72a882b 100644 --- a/src/Plugin/os2web/DataLookup/DatafordelerPNumber.php +++ b/src/Plugin/os2web/DataLookup/DatafordelerPNumber.php @@ -24,8 +24,8 @@ class DatafordelerPNumber extends DatafordelerBase implements DataLookupCompanyI */ public function defaultConfiguration(): array { return [ - 'webserviceurl_live' => 'https://s5-certservices.datafordeler.dk/CVR/HentCVRData/1/REST/', - ] + parent::defaultConfiguration(); + 'webserviceurl_live' => 'https://s5-certservices.datafordeler.dk/CVR/HentCVRData/1/REST/', + ] + parent::defaultConfiguration(); } /** diff --git a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php index ccf5229..04256b8 100644 --- a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php +++ b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php @@ -2,9 +2,7 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; -use Drupal\Core\File\FileSystem; use Drupal\Core\Form\FormStateInterface; -use Drupal\key\KeyRepositoryInterface; use Drupal\os2web_datalookup\Exception\RuntimeException; use Drupal\os2web_audit\Service\Logger; @@ -45,19 +43,19 @@ public function __construct( */ public function defaultConfiguration(): array { return [ - 'mode_selector' => 0, - 'serviceagreementuuid' => '', - 'serviceuuid' => '', - 'wsdl' => '', - 'location' => '', - 'location_test' => '', - 'usersystemuuid' => '', - 'useruuid' => '', - 'accountinginfo' => '', - 'certfile_passphrase' => '', - 'certfile' => '', - 'certfile_test' => '', - ] + parent::defaultConfiguration(); + 'mode_selector' => 0, + 'serviceagreementuuid' => '', + 'serviceuuid' => '', + 'wsdl' => '', + 'location' => '', + 'location_test' => '', + 'usersystemuuid' => '', + 'useruuid' => '', + 'accountinginfo' => '', + 'certfile_passphrase' => '', + 'certfile' => '', + 'certfile_test' => '', + ] + parent::defaultConfiguration(); } /** From f0eb235e54fec4960335bc1fc3ddc9f9a7595381 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Wed, 1 May 2024 17:09:53 +0200 Subject: [PATCH 3/8] Normalized composer.json --- composer.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 2151e58..6f707c0 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,6 @@ { "name": "os2web/os2web_datalookup", - "type": "drupal-module", "description": "Provides integration with Danish data lookup services such as Service platformen or Datafordeler.", - "minimum-stability": "dev", - "prefer-stable": true, "license": "EUPL-1.2", "require": { "os2web/os2web_key": "dev-os2web_key" @@ -11,7 +8,7 @@ "repositories": { "os2web/os2web_key": { "type": "vcs", - "url": "https://github.com/rimi-itk/os2web_key" + "url": "https://github.com/itk-dev/os2web_key" }, "drupal": { "type": "composer", From 9aaeb3248706f584bda522d413ad81cf66de6a19 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 7 May 2024 14:38:29 +0200 Subject: [PATCH 4/8] Added support for os2web_key --- os2web_datalookup.info.yml | 2 ++ os2web_datalookup.install | 9 +++++++++ src/Plugin/os2web/DataLookup/DatafordelerBase.php | 2 +- src/Plugin/os2web/DataLookup/ServiceplatformenBase.php | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/os2web_datalookup.info.yml b/os2web_datalookup.info.yml index c0abace..9454c79 100644 --- a/os2web_datalookup.info.yml +++ b/os2web_datalookup.info.yml @@ -3,5 +3,7 @@ type: module description: 'Provides integration with Danish data lookup services such as Service platformen or Datafordeler.' package: 'OS2web' core_version_requirement: ^8 || ^9 || ^10 + dependencies: - 'os2web:os2web_audit' + - 'os2web_key:os2web_key' diff --git a/os2web_datalookup.install b/os2web_datalookup.install index 55bc8c5..e0119a3 100644 --- a/os2web_datalookup.install +++ b/os2web_datalookup.install @@ -33,3 +33,12 @@ function os2web_datalookup_update_9003(): void { $config->set("pnumber_lookup.default_plugin", 'datafordeler_pnumber'); $config->save(); } + +/** + * Implements hook_update_N(). + */ +function os2web_datalookup_update_9004() { + \Drupal::service('module_installer')->install([ + 'os2web_key', + ], TRUE); +} diff --git a/src/Plugin/os2web/DataLookup/DatafordelerBase.php b/src/Plugin/os2web/DataLookup/DatafordelerBase.php index b5667aa..8aac78d 100644 --- a/src/Plugin/os2web/DataLookup/DatafordelerBase.php +++ b/src/Plugin/os2web/DataLookup/DatafordelerBase.php @@ -98,7 +98,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta 'certificate_key' => [ '#type' => 'key_select', '#key_filters' => [ - 'type' => 'os2web_certificate', + 'type' => 'os2web_key_certificate', ], '#title' => $this->t('Key'), '#default_value' => $this->configuration['certificate_key'] ?? NULL, diff --git a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php index 04256b8..a7a727c 100644 --- a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php +++ b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php @@ -143,7 +143,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta 'certificate_key' => [ '#type' => 'key_select', '#key_filters' => [ - 'type' => 'os2web_certificate', + 'type' => 'os2web_key_certificate', ], '#title' => $this->t('Key'), '#default_value' => $this->configuration['certificate_key'] ?? NULL, From a7a397ebef6007337f1f83ac7da991bef70909a8 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 13 May 2024 09:16:01 +0200 Subject: [PATCH 5/8] Required os2web_key 1.0 --- composer.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 6f707c0..12bec7a 100644 --- a/composer.json +++ b/composer.json @@ -3,13 +3,9 @@ "description": "Provides integration with Danish data lookup services such as Service platformen or Datafordeler.", "license": "EUPL-1.2", "require": { - "os2web/os2web_key": "dev-os2web_key" + "os2web/os2web_key": "^1.0" }, "repositories": { - "os2web/os2web_key": { - "type": "vcs", - "url": "https://github.com/itk-dev/os2web_key" - }, "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" From 8e8561a0988f52bf5197994775d3000b71f1cf29 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 13 May 2024 11:02:41 +0200 Subject: [PATCH 6/8] Added changelog # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0243377..4986648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* [PR-13](https://github.com/OS2web/os2web_datalookup/pull/13) + Added support for [os2web_key](https://github.com/OS2web/os2web_key) + ## [2.0.4] 2025-01-29 * Ensure postal code is only added to city if `CVRAdresse_postdistrikt` is not set. From d28b14fb6737150bc3c2d1c6f68d9575eec7772a Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 20 Dec 2024 10:44:38 +0100 Subject: [PATCH 7/8] Updated --- .github/workflows/pr.yml | 7 ++- README.md | 8 ++-- composer.json | 41 +++++++++------- src/Exception/RuntimeException.php | 2 +- .../os2web/DataLookup/DataLookupBase.php | 47 +++++-------------- .../os2web/DataLookup/DatafordelerBase.php | 10 ++-- .../DataLookup/ServiceplatformenBase.php | 6 ++- 7 files changed, 59 insertions(+), 62 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 132f08e..c9e4dc2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ '8.1' ] + php-versions: [ '8.3' ] dependency-version: [ prefer-lowest, prefer-stable ] steps: - uses: actions/checkout@master @@ -49,13 +49,16 @@ jobs: composer validate --strict composer.json # Check that dependencies resolve. composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + - name: Check that composer file is normalized + run: | + composer normalize --dry-run php-coding-standards: name: PHP coding standards runs-on: ubuntu-latest strategy: matrix: - php-versions: [ '8.1' ] + php-versions: [ '8.3' ] steps: - uses: actions/checkout@master - name: Setup PHP, with composer and extensions diff --git a/README.md b/README.md index 2280234..ebf5236 100644 --- a/README.md +++ b/README.md @@ -108,11 +108,11 @@ run the checks locally. ### PHP ```shell -docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer install +docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer install # Fix (some) coding standards issues -docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-apply +docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-apply # Check that code adheres to the coding standards -docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer coding-standards-check +docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm composer coding-standards-check ``` ### Markdown @@ -130,5 +130,5 @@ Running statis code analysis on a standalone Drupal module is a bit tricky, so w analysis: ```shell -docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm ./scripts/code-analysis +docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.3-fpm ./scripts/code-analysis ``` diff --git a/composer.json b/composer.json index 12bec7a..fb62caa 100644 --- a/composer.json +++ b/composer.json @@ -2,9 +2,18 @@ "name": "os2web/os2web_datalookup", "description": "Provides integration with Danish data lookup services such as Service platformen or Datafordeler.", "license": "EUPL-1.2", + "type": "drupal-module", "require": { + "ext-soap": "*", "os2web/os2web_key": "^1.0" }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "drupal/coder": "^8.3", + "ergebnis/composer-normalize": "^2.45", + "os2web/os2web_audit": "^0.1", + "phpunit/phpunit": "^9.5" + }, "repositories": { "drupal": { "type": "composer", @@ -15,29 +24,27 @@ "url": "https://asset-packagist.org" } }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "drupal/coder": "^8.3", - "phpunit/phpunit": "^9.5", - "os2web/os2web_audit": "^0.1" + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "ergebnis/composer-normalize": true + }, + "sort-packages": true }, "scripts": { - "coding-standards-check/phpcs": [ - "phpcs --standard=phpcs.xml.dist" - ], - "coding-standards-check": [ - "@coding-standards-check/phpcs" + "coding-standards-apply": [ + "@coding-standards-apply/phpcs" ], "coding-standards-apply/phpcs": [ "phpcbf --standard=phpcs.xml.dist" ], - "coding-standards-apply": [ - "@coding-standards-apply/phpcs" + "coding-standards-check": [ + "@coding-standards-check/phpcs" + ], + "coding-standards-check/phpcs": [ + "phpcs --standard=phpcs.xml.dist" ] - }, - "config": { - "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true - } } } diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php index 0dd1e03..1631731 100644 --- a/src/Exception/RuntimeException.php +++ b/src/Exception/RuntimeException.php @@ -3,7 +3,7 @@ namespace Drupal\os2web_datalookup\Exception; /** - * + * Runtime exception. */ class RuntimeException extends \RuntimeException { diff --git a/src/Plugin/os2web/DataLookup/DataLookupBase.php b/src/Plugin/os2web/DataLookup/DataLookupBase.php index a55c6fe..c2aa0b7 100644 --- a/src/Plugin/os2web/DataLookup/DataLookupBase.php +++ b/src/Plugin/os2web/DataLookup/DataLookupBase.php @@ -2,6 +2,7 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; +use Drupal\Core\File\FileExists; use Drupal\Core\File\FileSystem; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -22,14 +23,16 @@ * @see plugin_api */ abstract class DataLookupBase extends PluginBase implements DataLookupInterface, ContainerFactoryPluginInterface { - protected const PROVIDER_TYPE_FORM = 'form'; - protected const PROVIDER_TYPE_KEY = 'key'; + protected const string PROVIDER_TYPE_FORM = 'form'; + protected const string PROVIDER_TYPE_KEY = 'key'; /** * Local certificate path. * - * Used to temporarily store a certificate in a file just before calling a webservice. - * For security purposes, the file will be removed right after the webservice calls completes. + * Used to temporarily store a certificate in a file just before calling a + * webservice. + * For security purposes, the file will be removed right after the webservice + * call completes (even unsuccessfully). * * @var string */ @@ -42,13 +45,6 @@ abstract class DataLookupBase extends PluginBase implements DataLookupInterface, */ protected bool $isReady = TRUE; - /** - * Audit logger. - * - * @var \Drupal\os2web_audit\Service\Logger - */ - protected Logger $auditLogger; - /** * {@inheritdoc} */ @@ -56,20 +52,20 @@ public function __construct( array $configuration, $plugin_id, $plugin_definition, - Logger $auditLogger, + protected Logger $auditLogger, protected KeyRepositoryInterface $keyRepository, protected FileSystem $fileSystem, ) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->auditLogger = $auditLogger; $this->setConfiguration($configuration); - $this->init(); } /** - * + * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + /** @var \Drupal\os2web_audit\Service\Logger $auditLogger */ + $auditLogger = $container->get('os2web_audit.logger'); /** @var \Drupal\key\KeyRepositoryInterface $keyRepository */ $keyRepository = $container->get('key.repository'); /** @var \Drupal\Core\File\FileSystem $fileSystem */ @@ -79,29 +75,12 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, + $auditLogger, $keyRepository, $fileSystem ); } - /** - * Plugin init method. - */ - protected function init() { - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('os2web_audit.logger'), - ); - } - /** * {@inheritdoc} */ @@ -194,7 +173,7 @@ protected function writeCertificateToFile(): string { // Write certificate to local_cert location. $certificate = $this->getCertificate(); $localCertPath = $this->localCertPath; - $result = $this->fileSystem->saveData($certificate, $localCertPath, FileSystem::EXISTS_REPLACE); + $result = $this->fileSystem->saveData($certificate, $localCertPath, FileExists::Replace); if (!$result) { return new RuntimeException(sprintf('Error writing certificate to temporary file %s', $localCertPath)); } diff --git a/src/Plugin/os2web/DataLookup/DatafordelerBase.php b/src/Plugin/os2web/DataLookup/DatafordelerBase.php index 8aac78d..4d39fae 100644 --- a/src/Plugin/os2web/DataLookup/DatafordelerBase.php +++ b/src/Plugin/os2web/DataLookup/DatafordelerBase.php @@ -2,7 +2,9 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; +use Drupal\Core\File\FileSystem; use Drupal\Core\Form\FormStateInterface; +use Drupal\key\KeyRepositoryInterface; use Drupal\os2web_datalookup\Exception\RuntimeException; use Drupal\os2web_audit\Service\Logger; use GuzzleHttp\Client; @@ -28,15 +30,17 @@ public function __construct( $plugin_id, $plugin_definition, Logger $auditLogger, + KeyRepositoryInterface $keyRepository, + FileSystem $fileSystem, ) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $auditLogger); + parent::__construct($configuration, $plugin_id, $plugin_definition, $auditLogger, $keyRepository, $fileSystem); $this->init(); } /** * {@inheritdoc} */ - private function init(): void { + protected function init(): void { $this->isReady = FALSE; $configuration = $this->getConfiguration(); @@ -159,7 +163,7 @@ protected function getResponse(string $uri, array $options): ResponseInterface { return $this->httpClient->get($uri, $options); } finally { // Remove temporary certificate file. - if (file_exists($localCertPath)) { + if (isset($localCertPath) && file_exists($localCertPath)) { unlink($localCertPath); } } diff --git a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php index a7a727c..835e08f 100644 --- a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php +++ b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php @@ -2,7 +2,9 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; +use Drupal\Core\File\FileSystem; use Drupal\Core\Form\FormStateInterface; +use Drupal\key\KeyRepositoryInterface; use Drupal\os2web_datalookup\Exception\RuntimeException; use Drupal\os2web_audit\Service\Logger; @@ -33,8 +35,10 @@ public function __construct( $plugin_id, $plugin_definition, Logger $auditLogger, + KeyRepositoryInterface $keyRepository, + FileSystem $fileSystem, ) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $auditLogger); + parent::__construct($configuration, $plugin_id, $plugin_definition, $auditLogger, $keyRepository, $fileSystem); $this->init(); } From c717a5b048d4c89eaae8bcb2aa562723ee8a9676 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Fri, 2 May 2025 14:52:51 +0200 Subject: [PATCH 8/8] Updated cache version --- .github/workflows/pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c9e4dc2..547705a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -39,7 +39,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -73,7 +73,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}