Skip to content

Commit d6245d3

Browse files
committed
Adding REST UI module
1 parent b3cb840 commit d6245d3

File tree

16 files changed

+1144
-2
lines changed

16 files changed

+1144
-2
lines changed

app/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"drupal/elasticsearch_connector": "^7.0",
2424
"drupal/graphql": "4.x-dev",
2525
"drupal/redis": "^1.4",
26+
"drupal/restui": "1.x-dev",
2627
"drupal/search_api": "^1.15",
2728
"drupal/simple_oauth": "^4.4"
2829
},

app/composer.lock

Lines changed: 57 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/modules/contrib/restui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

app/modules/contrib/restui/README.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
REST UI
2+
=======
3+
4+
This module provides a user interface to manage REST resources.
5+
6+
Installation
7+
============
8+
9+
Once the module has been installed, navigate to admin/config/services/rest
10+
(Configuration > Web Services > REST through the administration panel) and
11+
configure the available resources.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: REST UI
2+
type: module
3+
description: "Provides a user interface to manage REST resources."
4+
package: Web services
5+
core: 8.x
6+
configure: restui.list
7+
dependencies:
8+
- drupal:rest
9+
- drupal:system (>=8.2.0)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
restui.list:
2+
title: REST
3+
description: 'Configure REST server settings.'
4+
parent: system.admin_config_services
5+
route_name: restui.list
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Hook implementations for REST UI module.
6+
*/
7+
8+
use Drupal\Core\Routing\RouteMatchInterface;
9+
10+
/**
11+
* Implements hook_help().
12+
*/
13+
function restui_help($route_name, RouteMatchInterface $route_match) {
14+
switch ($route_name) {
15+
case 'restui.edit':
16+
return '<p>' . t('Here you can restrict which HTTP methods should this resource support. And within each method, the available serialization formats and authentication providers.') . '</p>';
17+
}
18+
}
19+
20+
/**
21+
* Implements hook_theme().
22+
*/
23+
function restui_theme() {
24+
return [
25+
// List resources.
26+
'restui_resource_info' => [
27+
'variables' => [
28+
'granularity' => [],
29+
'configuration' => [],
30+
],
31+
'template' => 'restui-resource-info',
32+
],
33+
];
34+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Post update functions for REST UI.
6+
*/
7+
8+
/**
9+
* Simplify method-granularity REST resource config to resource-granularity.
10+
*
11+
* Re-runs the REST module's update path, because the REST UI module only
12+
* allowed creating 'method' granularity resources until version 1.14.
13+
*
14+
* @see https://www.drupal.org/node/2869443
15+
* @see https://www.drupal.org/node/2721595
16+
*/
17+
function restui_post_update_resource_granularity() {
18+
require_once \Drupal::root() . '/core/modules/rest/rest.post_update.php';
19+
rest_post_update_resource_granularity();
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
restui.list:
2+
path: '/admin/config/services/rest'
3+
defaults:
4+
_controller: '\Drupal\restui\Controller\RestUIController::listResources'
5+
requirements:
6+
_permission: 'administer rest resources'
7+
8+
restui.disable:
9+
path: '/admin/config/services/rest/resource/{resource_id}/disable'
10+
defaults:
11+
_controller: '\Drupal\restui\Controller\RestUIController::disable'
12+
requirements:
13+
_permission: 'administer rest resources'
14+
_csrf_token: 'TRUE'
15+
16+
restui.edit:
17+
path: '/admin/config/services/rest/resource/{resource_id}/edit'
18+
defaults:
19+
_form: '\Drupal\restui\Form\RestUIForm'
20+
requirements:
21+
_permission: 'administer rest resources'

0 commit comments

Comments
 (0)