This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
relaxed.install
62 lines (56 loc) · 1.62 KB
/
relaxed.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
use Drupal\Core\Serialization\Yaml;
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*/
function relaxed_install() {
// Demonstrate best security practice and create a separate role with the
// only permissions needed to perform content replication.
$rid = 'replicator';
$replicator_role = Role::load($rid);
if (empty($replicator_role)) {
Role::create([
'id' => $rid,
'label' => 'Replicator',
'weight' => 0,
'is_admin' => 0,
'permissions' => [
'perform push replication',
'administer users',
'administer workspaces',
'bypass node access',
],
])->save();
}
}
/**
* Load new rest configuration for RESTful Web Services module.
*/
function relaxed_update_8301() {
\Drupal::state()->set('relaxed_update_8301_resources', \Drupal::config('rest.settings')->get('resources'));
\Drupal::configFactory()->getEditable('rest.settings')
->clear('resources')
->save();
}
/**
* Load new rest configuration.
*/
function relaxed_update_8302() {
\Drupal::state()->set('relaxed_update_8302_resources', \Drupal::config('rest.settings')->get('resources'));
\Drupal::configFactory()->getEditable('rest.settings')
->clear('resources')
->save();
}
/**
* Update REST config for Changes endpoint.
*/
function relaxed_update_8303() {
$config_factory = \Drupal::configFactory();
$config_name = 'rest.resource.relaxed.changes';
$config_data = file_get_contents(__DIR__ . "/config/optional/{$config_name}.yml");
$config = Yaml::decode($config_data);
$config_factory->getEditable($config_name)
->setData($config)
->save(TRUE);
}