Skip to content

Commit 9499dad

Browse files
authored
Merge pull request #2 from OS2web/sprint-2
OS2Forms Sprint 2
2 parents f67d067 + 2b4c8dd commit 9499dad

18 files changed

+625
-6
lines changed

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
language: php
2+
3+
sudo: false
4+
5+
php:
6+
- 7.2
7+
8+
install:
9+
- composer global require drush/drush:8.x-dev drupal/coder mglaman/drupal-check friendsoftwig/twigcs
10+
- export PATH="$HOME/.config/composer/vendor/bin:$PATH"
11+
- phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer
12+
- phpenv rehash
13+
- nvm install node
14+
- nvm use node
15+
- npm install --global yarn
16+
- cd ../ && drush dl drupal-8 --drupal-project-rename=drupal
17+
- cd drupal
18+
- DRUPAL_ROOT=$(pwd)
19+
- export REPOSITORIES='"repositories":\ \['
20+
- export REPOSITORIES_REPLACE='"repositories":\[\{"type":"path","url":"..\/os2web_datalookup","options":\{"symlink":false\}\},'
21+
- export REQUIRE='"require":\ {'
22+
- export REQUIRE_REPLACE='"require":{"os2web\/os2web_datalookup":"\*",'
23+
- sed -i "s/$REPOSITORIES/$REPOSITORIES_REPLACE/g" composer.json
24+
- sed -i "s/$REQUIRE/$REQUIRE_REPLACE/g" composer.json
25+
- composer update
26+
- PROJECT_PATH=$DRUPAL_ROOT/modules/contrib/os2web_datalookup
27+
- cd $DRUPAL_ROOT/core
28+
- yarn install
29+
- npm install --global eslint-config-drupal-bundle stylelint
30+
31+
script:
32+
- phpcs --standard=Drupal --ignore=*.md $PROJECT_PATH
33+
- twigcs $PROJECT_PATH
34+
- cd $DRUPAL_ROOT/core
35+
- eslint $PROJECT_PATH
36+
- stylelint --aei $PROJECT_PATH/**/*.css
37+
- drupal-check $PROJECT_PATH

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
# OS2Web Data lookup [![Build Status](https://travis-ci.org/OS2web/os2web_datalookup.svg?branch=8.x)](https://travis-ci.org/OS2web/os2web_datalookup)
22
## Install
33

4-
OS2Forms Drupal 8 module is available to download via composer.
4+
OS2Web Data lookup provides integration with Danish data lookup services such as Service platformen or Datafordeler.
5+
Module is available to download via composer.
56
```
67
composer require os2web/os2web_datalookup
78
drush en os2web_datalookup
89
```
910

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

1415
```
1516
composer outdated os2web/os2web_datalookup
1617
```
1718

1819
## Automated testing and code quality
19-
See [OS2Forms testing and CI information](https://github.com/OS2Forms/docs#testing-and-ci)
20+
See [OS2Web testing and CI information](https://github.com/OS2Web/docs#testing-and-ci)
2021

2122
## Contribution
2223

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

2930
### Code review policy
30-
See [OS2Forms code review policy](https://github.com/OS2Forms/docs#code-review)
31+
See [OS2Web code review policy](https://github.com/OS2Web/docs#code-review)
3132

3233
### Git name convention
33-
See [OS2Forms git name convention](https://github.com/OS2Forms/docs#git-guideline)
34+
See [OS2Web git name convention](https://github.com/OS2Web/docs#git-guideline)

composer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "os2web/os2web_datalookup",
3+
"type": "drupal-module",
4+
"description": "Provides integration with Danish data lookup services such as Service platformen or Datafordeler.",
5+
"minimum-stability": "dev",
6+
"prefer-stable": true,
7+
"license": "EUPL-1.2",
8+
"repositories": {
9+
"drupal": {
10+
"type": "composer",
11+
"url": "https://packages.drupal.org/8"
12+
},
13+
"assets": {
14+
"type": "composer",
15+
"url": "https://asset-packagist.org"
16+
}
17+
}
18+
}

os2web_datalookup.info.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: 'OS2Web datalookup'
2+
type: module
3+
description: 'Provides integration with Danish data lookup services such as Service platformen or Datafordeler.'
4+
package: OS2
5+
core: 8.x
6+
core_version_requirement: ^8 || ^9

os2web_datalookup.links.menu.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
os2web_datalookup.status_list:
2+
title: 'OS2Web Datalookup'
3+
parent: system.admin_config_system
4+
description: 'OS2Web Datalookup status page'
5+
route_name: os2web_datalookup.status_list
6+
weight: -20

os2web_datalookup.permissions.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
administer os2web datalookup configuration:
2+
title: 'Administer OS2Web datalookup configuration'
3+
description: 'Permission for administrating the OS2Web datalookup configuration.'
4+
restrict access: TRUE

os2web_datalookup.routing.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
os2web_datalookup.status_list:
2+
path: '/admin/config/system/os2web-datalookup'
3+
defaults:
4+
_controller: '\Drupal\os2web_datalookup\Controller\DatalookupController::statusList'
5+
_title: 'OS2Web Datalookup'
6+
requirements:
7+
_permission: 'administer os2web datalookup configuration'
8+
9+
route_callbacks:
10+
- '\Drupal\os2web_datalookup\Routing\DataLookupRoutes::routes'

os2web_datalookup.services.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
services:
2+
plugin.manager.os2web_datalookup:
3+
class: Drupal\os2web_datalookup\Plugin\DataLookupManager
4+
parent: default_plugin_manager

src/Annotation/DataLookup.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Drupal\os2web_datalookup\Annotation;
4+
5+
use Drupal\Component\Annotation\Plugin;
6+
7+
/**
8+
* Defines a AuthProvider annotation object.
9+
*
10+
* Plugin Namespace: Plugin/os2web/DataLookup.
11+
*
12+
* @see hook_os2web_nemlogin_auth_provider_info_alter()
13+
* @see \Drupal\os2web_datalookup\Plugin\DataLookupManager
14+
* @see plugin_api
15+
*
16+
* @Annotation
17+
*/
18+
class DataLookup extends Plugin {
19+
20+
/**
21+
* The plugin ID.
22+
*
23+
* @var string
24+
*/
25+
public $id;
26+
27+
/**
28+
* The human-readable name of the consent storage.
29+
*
30+
* @var \Drupal\Core\Annotation\Translation
31+
*
32+
* @ingroup plugin_translatable
33+
*/
34+
public $label;
35+
36+
/**
37+
* A brief description of the consent storage.
38+
*
39+
* This will be shown when adding or configuring this consent storage.
40+
*
41+
* @var \Drupal\Core\Annotation\Translation
42+
*
43+
* @ingroup plugin_translatable
44+
*/
45+
public $description = '';
46+
47+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
namespace Drupal\os2web_datalookup\Controller;
4+
5+
use Drupal\Component\Plugin\PluginManagerInterface;
6+
use Drupal\Core\Controller\ControllerBase;
7+
use Drupal\Core\Link;
8+
use Symfony\Component\DependencyInjection\ContainerInterface;
9+
10+
/**
11+
* Class DatalookupController.
12+
*
13+
* @package Drupal\os2web_datalookup\Controller
14+
*/
15+
class DatalookupController extends ControllerBase {
16+
17+
/**
18+
* The manager to be used for instantiating plugins.
19+
*
20+
* @var \Drupal\Component\Plugin\PluginManagerInterface
21+
*/
22+
protected $manager;
23+
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function __construct(PluginManagerInterface $manager) {
28+
$this->manager = $manager;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public static function create(ContainerInterface $container) {
35+
return new static(
36+
$container->get('plugin.manager.os2web_datalookup')
37+
);
38+
}
39+
40+
/**
41+
* Status list callback.
42+
*/
43+
public function statusList() {
44+
$headers = [
45+
'title' => $this
46+
->t('Title'),
47+
'status' => $this
48+
->t('Status'),
49+
'action' => $this
50+
->t('Actions'),
51+
];
52+
53+
$rows = [];
54+
foreach ($this->manager->getDefinitions() as $id => $plugin_definition) {
55+
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterface $plugin */
56+
$plugin = $this->manager->createInstance($id);
57+
$status = $plugin->getStatus();
58+
if (empty($status)) {
59+
$status = $this->t('Failed');
60+
}
61+
$rows[$id] = [
62+
'title' => $plugin_definition['label'],
63+
'status' => $status,
64+
'action' => Link::createFromRoute($this->t('Settings'), "os2web_datalookup.$id"),
65+
];
66+
}
67+
68+
return [
69+
'#theme' => 'table',
70+
'#header' => $headers,
71+
'#rows' => $rows,
72+
];
73+
}
74+
75+
}

0 commit comments

Comments
 (0)