Skip to content

os2web_key #13

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

Open
wants to merge 33 commits into
base: 8.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2d603d2
ITKDev: Code style fixes in plugins
cableman Apr 24, 2024
d97324e
ITKDev: Added audit logging to lookups
cableman Apr 24, 2024
9ff36c6
ITKDev: Install file should not be executable
cableman Apr 24, 2024
9026846
ITKDev: Refactored audit logging
cableman Apr 26, 2024
2d58f15
ITKDev: Added github actions to check code style
cableman Apr 26, 2024
b111ebb
ITKDev: Removed markdown check
cableman May 7, 2024
90c5090
ITKDev: Allow plugins in composer
cableman May 7, 2024
babbaf1
ITKDev: Added code style
cableman May 7, 2024
996ff27
ITKDev: Code review changes
cableman May 7, 2024
711de21
ITKDev: Removed not used phpstan
cableman May 14, 2024
0f4896e
ITKDev: Added messing ")" to CVR plugin
cableman Aug 21, 2024
8d52bb8
ITKDev: Added audit module requirement to composer
cableman Oct 16, 2024
5918480
ITKDev: revert interface name
cableman Oct 18, 2024
5abb577
Added dependencies to os2web_audit module
cableman Oct 21, 2024
7ff5a97
Merge branch 'feature/os2form-audit' of https://github.com/itk-dev/os…
cableman Oct 21, 2024
876c756
ITKDev: fixed composer json
cableman Oct 21, 2024
827099d
ITKDev: Minor fixes
jekuaitk Oct 28, 2024
eb4d55b
Merge pull request #1 from itk-dev/feature/os2form-audit-update
cableman Oct 28, 2024
5d19dd4
ITKDev: Update create method
jekuaitk Oct 28, 2024
afa495f
ITKDev: Use ContainerFactoryPluginInterface
jekuaitk Oct 29, 2024
2387bb1
Merge pull request #2 from itk-dev/feature/os2forms-audit-fixes
jekuaitk Oct 29, 2024
9126c98
Merge pull request #12 from itk-dev/feature/os2form-audit
jekuaitk Nov 21, 2024
0b9fc2e
ITKDev: Update Serviceplatformen audit logging messages
jekuaitk Nov 22, 2024
d793776
Merge pull request #15 from itk-dev/feature/update-logging-messages
jekuaitk Nov 22, 2024
e78aba8
ITKDev: Fixes must not be accessed before initialization
cableman Nov 27, 2024
cadc545
Merge pull request #16 from itk-dev/feature/no-init-error
jekuaitk Dec 6, 2024
2c35b91
Added support for os2web_key
rimi-itk May 1, 2024
f47d07f
Defined coding standards and applied in select places
rimi-itk May 1, 2024
e8179de
Normalized composer.json
rimi-itk May 1, 2024
0b042d3
Added support for os2web_key
rimi-itk May 7, 2024
b14f82e
Required os2web_key 1.0
rimi-itk May 13, 2024
bc04861
Added changelog
rimi-itk May 13, 2024
2ca5bd7
Updated
rimi-itk Dec 20, 2024
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
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#### Link to ticket

Please add a link to the ticket being addressed by this change.

#### Description

Please include a short description of the suggested change and the reasoning behind the approach you have chosen.

#### Screenshot of the result

If your change affects the user interface you should include a screenshot of the result with the pull request.

#### Checklist

- [ ] My code passes our static analysis suite.
- [ ] My code passes our continuous integration process.

If your code does not pass all the requirements on the checklist you have to add a comment explaining why this change
should be exempt from the list.

#### Additional comments or questions

If you have any further comments or questions for the reviewer please add them here.
67 changes: 67 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,70 @@ jobs:

- name: Check that changelog has been updated.
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0

test-composer-files:
name: Validate composer
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.3' ]
dependency-version: [ prefer-lowest, prefer-stable ]
steps:
- uses: actions/checkout@master
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: json
coverage: none
tools: composer:v2
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Validate composer files
run: |
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.3' ]
steps:
- uses: actions/checkout@master
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: json
coverage: none
tools: composer:v2
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: |
composer install --no-interaction --no-progress
- name: PHPCS
run: |
composer coding-standards-check/phpcs
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
composer.lock
vendor/
19 changes: 19 additions & 0 deletions .markdownlintrc
Original file line number Diff line number Diff line change
@@ -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:
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

* [PR-13](https://github.com/OS2web/os2web_datalookup/pull/13)
Added support for [os2web_key](https://github.com/OS2web/os2web_key)

[Unreleased]: https://github.com/itk-dev/os2web_datalookup
93 changes: 69 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
# OS2Web Data lookup [![Build Status](https://travis-ci.org/OS2web/os2web_datalookup.svg?branch=8.x)](https://travis-ci.org/OS2web/os2web_datalookup)

## Install

OS2Web Data lookup provides integration with Danish data lookup services such as Service platformen or Datafordeler.
Module is available to download via composer.
```
OS2Web Data lookup provides integration with Danish data lookup services such as
Service platformen or Datafordeler. Module is available to download via
composer.

```shell
composer require os2web/os2web_datalookup
drush en os2web_datalookup
```

## Update
Updating process for OS2Web Data lookup module is similar to usual Drupal 8 module.
Use Composer's built-in command for listing packages that have updates available:

```
Updating process for OS2Web Data lookup module is similar to the usual Drupal 8
module. Use Composer's built-in command for listing packages that have updates
available:

```shell
composer outdated os2web/os2web_datalookup
```

## Automated testing and code quality

See [OS2Web testing and CI information](https://github.com/OS2Web/docs#testing-and-ci)

## Contribution

Project is opened for new features and os course bugfixes.
If you have any suggestion or you found a bug in project, you are very welcome
to create an issue in github repository issue tracker.
For issue description there is expected that you will provide clear and
sufficient information about your feature request or bug report.
If you have any suggestion, or you found a bug in project, you are very welcome
to create an issue in GitHub repository issue tracker. For issue description,
there is expected that you will provide clear and sufficient information about
your feature request or bug report.

### Code review policy

See [OS2Web code review policy](https://github.com/OS2Web/docs#code-review)

### Git name convention

See [OS2Web git name convention](https://github.com/OS2Web/docs#git-guideline)

### Using services in other modules

```
```php
// CVR lookup
/** @var \Drupal\os2web_datalookup\Plugin\DataLookupManager $pluginManager */
$pluginManager = \Drupal::service('plugin.manager.os2web_datalookup');
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCompany $cvrPlugin */
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupCompanyInterface $cvrPlugin */
$cvrPlugin = $pluginManager->createDefaultInstanceByGroup('cvr_lookup');

if ($cvrPlugin->isReady()) {
Expand All @@ -49,7 +57,7 @@ if ($cvrPlugin->isReady()) {
// CPR lookup.
/** @var \Drupal\os2web_datalookup\Plugin\DataLookupManager $pluginManager */
$pluginManager = \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 = $pluginManager->createDefaultInstanceByGroup('cpr_lookup');

if ($cprPlugin->isReady()) {
Expand All @@ -66,24 +74,61 @@ if ($cprPlugin->isReady()) {

## New services/features

### Datafordeler integration (https://datafordeler.dk)
### Datafordeler integration (<https://datafordeler.dk>)

In the scope of os2forms project already implemented light integration with
Danmarks Adresseregister (DAR) via fetching data for form elements autocomplete.

In scope of os2forms project already implemented light integration
with Danmarks Adresseregister (DAR) via fetching data for form elements
autocomplete. See [os2forms_dawa submodule](https://github.com/OS2Forms/os2forms)
See [os2forms_dawa submodule](https://github.com/OS2Forms/os2forms)

As soon as it is clear how the integration is going to be used, then
os2forms_dawa will be refactored to OS2Web Data lookup plugin plugin.
os2forms_dawa will be refactored to OS2Web Data lookup plugin.

## Important notes

### Serviceplatformen plugins
Settings for CPR and CVR serviceplantormen plugins are storing as configuration
in db and will(could) be exported as `yml` file via Drupal configuration
management system. And afterwards could be tracked by `git`.

If case you have public access to your git repository all setting from plugins
Settings for CPR and CVR serviceplatformen plugins are storing as configuration
in db and will(could) be exported as `yml` file via Drupal's configuration
management system. And afterward could be tracked by `git`.

If case you have public access to your git repository, all settings from plugins
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 configuration
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.3-fpm composer install
# Fix (some) coding standards issues
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.3-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.3-fpm ./scripts/code-analysis
```
37 changes: 33 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"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",
"type": "drupal-module",
"require": {
"ext-soap": "*"
"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": {
Expand All @@ -17,5 +23,28 @@
"type": "composer",
"url": "https://asset-packagist.org"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true
},
"sort-packages": true
},
"scripts": {
"coding-standards-apply": [
"@coding-standards-apply/phpcs"
],
"coding-standards-apply/phpcs": [
"phpcbf --standard=phpcs.xml.dist"
],
"coding-standards-check": [
"@coding-standards-check/phpcs"
],
"coding-standards-check/phpcs": [
"phpcs --standard=phpcs.xml.dist"
]
}
}
4 changes: 4 additions & 0 deletions os2web_datalookup.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +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'
20 changes: 17 additions & 3 deletions os2web_datalookup.install
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?php

/**
* @file
* Install, uninstall and update hooks for the module.
*/

use Drupal\os2web_datalookup\Form\DataLookupPluginGroupSettingsForm;

/**
* Setting "serviceplatformen_cpr_extended" as default CPR lookup plugin.
*/
function os2web_datalookup_update_9001() {
function os2web_datalookup_update_9001(): void {
$config = \Drupal::service('config.factory')->getEditable(DataLookupPluginGroupSettingsForm::$configName);
$config->set("cpr_lookup.default_plugin", 'serviceplatformen_cpr_extended');
$config->save();
Expand All @@ -14,7 +19,7 @@ function os2web_datalookup_update_9001() {
/**
* Setting "datafordeler_cvr" as default CVR lookup plugin.
*/
function os2web_datalookup_update_9002() {
function os2web_datalookup_update_9002(): void {
$config = \Drupal::service('config.factory')->getEditable(DataLookupPluginGroupSettingsForm::$configName);
$config->set("cvr_lookup.default_plugin", 'datafordeler_cvr');
$config->save();
Expand All @@ -23,8 +28,17 @@ function os2web_datalookup_update_9002() {
/**
* Setting "datafordeler_pnumber" as default P-Number lookup plugin.
*/
function os2web_datalookup_update_9003() {
function os2web_datalookup_update_9003(): void {
$config = \Drupal::service('config.factory')->getEditable(DataLookupPluginGroupSettingsForm::$configName);
$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);
}
Loading
Loading