Skip to content

Commit d126a8b

Browse files
authored
Merge pull request #3 from OS2web/sprint-3
OS2Forms Sprint 3
2 parents 9499dad + 24234a7 commit d126a8b

File tree

53 files changed

+3303
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3303
-19
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ install:
1313
- nvm install node
1414
- nvm use node
1515
- npm install --global yarn
16-
- cd ../ && drush dl drupal-8 --drupal-project-rename=drupal
16+
- cd ../ && composer create-project drupal-composer/drupal-project:8.x-dev drupal --no-interaction
1717
- cd drupal
18-
- DRUPAL_ROOT=$(pwd)
18+
- DRUPAL_ROOT=$(pwd)/web
1919
- export REPOSITORIES='"repositories":\ \['
2020
- export REPOSITORIES_REPLACE='"repositories":\[\{"type":"path","url":"..\/os2web_datalookup","options":\{"symlink":false\}\},'
2121
- export REQUIRE='"require":\ {'
2222
- export REQUIRE_REPLACE='"require":{"os2web\/os2web_datalookup":"\*",'
2323
- sed -i "s/$REPOSITORIES/$REPOSITORIES_REPLACE/g" composer.json
2424
- sed -i "s/$REQUIRE/$REQUIRE_REPLACE/g" composer.json
25-
- composer update
25+
- composer update os2web/os2web_datalookup
2626
- PROJECT_PATH=$DRUPAL_ROOT/modules/contrib/os2web_datalookup
2727
- cd $DRUPAL_ROOT/core
2828
- yarn install

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,21 @@ See [OS2Web code review policy](https://github.com/OS2Web/docs#code-review)
3232

3333
### Git name convention
3434
See [OS2Web git name convention](https://github.com/OS2Web/docs#git-guideline)
35+
36+
### Using services in other modules
37+
38+
```
39+
\Drupal::service('plugin.manager.os2web_datalookup')->createInstance('serviceplatformen_cvr')->getLegalUnit('[CVR number]')
40+
\Drupal::service('plugin.manager.os2web_datalookup')->createInstance('serviceplatformen_cpr')->cprBasicInformation('[CPR number]'))
41+
```
42+
43+
## New services/features
44+
45+
### Datafordeler integration (https://datafordeler.dk)
46+
47+
In scope of os2forms project already implemented light integration
48+
with Danmarks Adresseregister (DAR) via fetching data for form elements
49+
autocomplete. See [os2forms_dawa submodule](https://github.com/OS2Forms/os2forms)
50+
51+
As soon as it is clear how the integration is going to be used, then
52+
os2forms_dawa will be refactored to OS2Web Data lookup plugin plugin.

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"minimum-stability": "dev",
66
"prefer-stable": true,
77
"license": "EUPL-1.2",
8+
"require": {
9+
"ext-soap": "*"
10+
},
811
"repositories": {
912
"drupal": {
1013
"type": "composer",

os2web_datalookup.services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
services:
22
plugin.manager.os2web_datalookup:
33
class: Drupal\os2web_datalookup\Plugin\DataLookupManager
4-
parent: default_plugin_manager
4+
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler', '@config.factory']

src/Controller/DatalookupController.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,11 @@ public function statusList() {
5252

5353
$rows = [];
5454
foreach ($this->manager->getDefinitions() as $id => $plugin_definition) {
55-
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterface $plugin */
5655
$plugin = $this->manager->createInstance($id);
5756
$status = $plugin->getStatus();
58-
if (empty($status)) {
59-
$status = $this->t('Failed');
60-
}
6157
$rows[$id] = [
6258
'title' => $plugin_definition['label'],
63-
'status' => $status,
59+
'status' => ($plugin->isReady() ? $this->t('READY') : $this->t('ERROR')) . ': ' . $status,
6460
'action' => Link::createFromRoute($this->t('Settings'), "os2web_datalookup.$id"),
6561
];
6662
}

src/Plugin/DataLookupManager.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Drupal\os2web_datalookup\Plugin;
44

5+
use Drupal\Core\Config\ConfigFactoryInterface;
56
use Drupal\Core\Plugin\DefaultPluginManager;
67
use Drupal\Core\Cache\CacheBackendInterface;
78
use Drupal\Core\Extension\ModuleHandlerInterface;
9+
use Drupal\os2web_datalookup\Form\DataLookupPluginSettingsForm;
810

911
/**
1012
* DataLookupManager plugin manager.
@@ -15,6 +17,13 @@
1517
*/
1618
class DataLookupManager extends DefaultPluginManager {
1719

20+
/**
21+
* The config factory.
22+
*
23+
* @var \Drupal\Core\Config\ConfigFactoryInterface
24+
*/
25+
protected $configFactory;
26+
1827
/**
1928
* Constructs an DataLookupManager object.
2029
*
@@ -25,8 +34,10 @@ class DataLookupManager extends DefaultPluginManager {
2534
* Cache backend instance to use.
2635
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
2736
* The module handler to invoke the alter hook with.
37+
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
38+
* The config factory.
2839
*/
29-
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
40+
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) {
3041
parent::__construct(
3142
'Plugin/os2web/DataLookup',
3243
$namespaces,
@@ -36,6 +47,17 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
3647

3748
$this->alterInfo('os2web_datalookup_info');
3849
$this->setCacheBackend($cache_backend, 'os2web_datalookup');
50+
$this->configFactory = $config_factory;
51+
}
52+
53+
/**
54+
* {@inheritdoc}
55+
*/
56+
public function createInstance($plugin_id, array $configuration = []) {
57+
if (empty($configuration)) {
58+
$configuration = $this->configFactory->get(DataLookupPluginSettingsForm::getConfigName() . '.' . $plugin_id)->get();
59+
}
60+
return parent::createInstance($plugin_id, $configuration);
3961
}
4062

4163
}

src/Plugin/os2web/DataLookup/DataLookupBase.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
*/
1818
abstract class DataLookupBase extends PluginBase implements DataLookupInterface {
1919

20+
/**
21+
* Plugin readiness flag.
22+
*
23+
* @var bool
24+
*/
25+
protected $isReady = TRUE;
26+
2027
/**
2128
* {@inheritdoc}
2229
*/
@@ -68,4 +75,11 @@ public function getStatus() {
6875
return 'N/A';
6976
}
7077

78+
/**
79+
* {@inheritdoc}
80+
*/
81+
public function isReady() {
82+
return $this->isReady;
83+
}
84+
7185
}

src/Plugin/os2web/DataLookup/DataLookupInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ interface DataLookupInterface extends PluginInspectionInterface, PluginFormInter
2121
*/
2222
public function getStatus();
2323

24+
/**
25+
* Get plugin readiness.
26+
*/
27+
public function isReady();
28+
2429
}

0 commit comments

Comments
 (0)