This repository has been archived by the owner on Oct 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
contentpool.install
89 lines (78 loc) · 2.94 KB
/
contentpool.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* @file
* Install file.
*/
use Drupal\Core\Config\FileStorage;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\user\Entity\Role;
use Drupal\user\Entity\User;
use Drupal\Core\Config\InstallStorage;
/**
* Install the contentpool installation profile.
*/
function contentpool_install() {
// Create a default replicator user.
$user = User::create([
'name' => 'replicator',
'status' => 1,
]);
$user->roles[] = 'replicator';
$user->save();
// Extend the replicator role permissions as needed.
$replicator = Role::load('replicator');
$replicator->grantPermission('restful post contentpool:remote_registration');
$replicator->grantPermission('restful get contentpool:contentpool_term_reference_fields');
$replicator->save();
// Adjust redirect module to disable route normalizing.
// See https://github.com/relaxedws/couchdb-replicator/issues/10.
\Drupal::configFactory()
->getEditable('redirect.settings')
->set('route_normalizer_enabled', FALSE)
->save();
// Add our custom install configuration.
// @see config/custom-install/README.txt
$source = new FileStorage(__DIR__ . '/config/custom-install');
$config_storage = \Drupal::service('config.storage');
foreach ($source->listAll() as $config_name) {
$config_storage->write($config_name, $source->read($config_name));
}
// For some reason paragraphs field storage gets not installed correctly,
// fix it.
$storage = FieldStorageConfig::load('node.field_paragraphs_markup');
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('field_paragraphs_markup', 'markup_field', 'node', $storage);
}
/**
* Grant replicator permission on the term reference ressource.
*/
function contentpool_update_8001() {
// Add new configuration.
$module_handler = \Drupal::service('module_handler');
$config_path = $module_handler->getModule('contentpool_remote_register')->getPath() . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
$source = new FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');
$config_storage->write('rest.resource.contentpool_term_reference_fields', $source->read('rest.resource.contentpool_term_reference_fields'));
// Extend the replicator role permissions as needed.
$replicator = Role::load('replicator');
$replicator->grantPermission('restful get contentpool:contentpool_term_reference_fields');
$replicator->save();
}
/**
* Add in custom config.
*/
function contentpool_update_8002() {
// Add our custom install configuration.
// @see config/custom-install/README.txt
$source = new FileStorage(__DIR__ . '/config/custom-install');
$config_storage = \Drupal::service('config.storage');
foreach ($source->listAll() as $config_name) {
$config_storage->write($config_name, $source->read($config_name));
}
}
/**
* Update to custom elements 2.x.
*/
function contentpool_update_8003() {
\Drupal::service('module_installer')->install(['custom_elements_thunder']);
}