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

os2web_key #13

Open
wants to merge 6 commits into
base: 8.x
Choose a base branch
from
Open
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
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
50 changes: 46 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# 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.
```

```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:

```
```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
Expand All @@ -28,14 +32,16 @@ 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');
Expand Down Expand Up @@ -66,7 +72,7 @@ if ($cprPlugin->isReady()) {

## New services/features

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

In scope of os2forms project already implemented light integration
with Danmarks Adresseregister (DAR) via fetching data for form elements
Expand All @@ -76,7 +82,9 @@ 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.

## 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`.
Expand All @@ -87,3 +95,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 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
```
43 changes: 39 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"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": "*",
"drupal/coder": "*",
"ergebnis/composer-normalize": "^2.42",
"mglaman/phpstan-drupal": "*",
"phpstan/extension-installer": "*",
"phpstan/phpstan-deprecation-rules": "*"
},
"repositories": {
"drupal": {
Expand All @@ -17,5 +24,33 @@
"type": "composer",
"url": "https://asset-packagist.org"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"cweagans/composer-patches": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true,
"simplesamlphp/composer-module-installer": true,
"vaimo/composer-patches": true,
"zaporylie/composer-drupal-optimizations": 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"
]
}
}
3 changes: 3 additions & 0 deletions os2web_datalookup.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ 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_key:os2web_key
9 changes: 9 additions & 0 deletions os2web_datalookup.install
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ function os2web_datalookup_update_9003() {
$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);
}
22 changes: 22 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="PHP_CodeSniffer">
<description>OS2Forms PHP Code Sniffer configuration</description>

<file>.</file>
<exclude-pattern>vendor/</exclude-pattern>
<exclude-pattern>node_modules/</exclude-pattern>

<!-- Show progress of the run -->
<arg value="p"/>

<arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,yml"/>
<config name="drupal_core_version" value="9"/>

<rule ref="Drupal">
<!-- We want to be able to use "package" and "version" in our custom modules -->
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Project"/>
<exclude name="Drupal.InfoFiles.AutoAddedKeys.Version"/>
</rule>

<rule ref="DrupalPractice"/>
</ruleset>
13 changes: 13 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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:
47 changes: 47 additions & 0 deletions scripts/code-analysis
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 10 additions & 0 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Drupal\os2web_datalookup\Exception;

/**
*
*/
class RuntimeException extends \RuntimeException {

}
Loading
Loading