Skip to content

Commit 2b4c8dd

Browse files
committed
Added status page
1 parent 2e00afe commit 2b4c8dd

8 files changed

+103
-5
lines changed

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
os2web_datalookup.status:
1+
os2web_datalookup.status_list:
22
path: '/admin/config/system/os2web-datalookup'
33
defaults:
4-
_controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage'
4+
_controller: '\Drupal\os2web_datalookup\Controller\DatalookupController::statusList'
55
_title: 'OS2Web Datalookup'
66
requirements:
77
_permission: 'administer os2web datalookup configuration'
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+
}

src/Form/DataLookupPluginSettingsForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function create(ContainerInterface $container) {
3333
* {@inheritdoc}
3434
*/
3535
public static function getConfigName() {
36-
return 'os2web_datalookup.settings';
36+
return 'os2web_datalookup';
3737
}
3838

3939
}

src/Plugin/os2web/DataLookup/DataLookupBase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,11 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form
6161
// Making validate optional.
6262
}
6363

64+
/**
65+
* {@inheritdoc}
66+
*/
67+
public function getStatus() {
68+
return 'N/A';
69+
}
70+
6471
}

src/Plugin/os2web/DataLookup/DataLookupInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@
1515
* @ingroup plugin_api
1616
*/
1717
interface DataLookupInterface extends PluginInspectionInterface, PluginFormInterface, ConfigurableInterface {
18+
19+
/**
20+
* Get plugin status.
21+
*/
22+
public function getStatus();
23+
1824
}

src/Routing/DataLookupRoutes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function routes() {
4848
$pluginDefinitions = $this->manager->getDefinitions();
4949
$routes = [];
5050
foreach ($pluginDefinitions as $id => $plugin) {
51-
$routes["os2web_nemlogin.auth_provider.$id"] = new Route(
52-
"admin/config/system/os2web-datalookup/" . str_replace('_', '-', $plugin['id']), [
51+
$routes["os2web_datalookup.$id"] = new Route(
52+
"/admin/config/system/os2web-datalookup/" . str_replace('_', '-', $plugin['id']), [
5353
'_form' => '\Drupal\os2web_datalookup\Form\DataLookupPluginSettingsForm',
5454
'_title' => t("Configure :label", [':label' => $plugin['label']->__toString()])->__toString(),
5555
'_plugin_id' => $id,

0 commit comments

Comments
 (0)