This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
draft.install
83 lines (73 loc) · 2.51 KB
/
draft.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
<?php
use Drupal\Core\Config\FileStorage;
use Drupal\Core\File\FileSystemInterface;
/**
* Implements hook_install_tasks().
*/
function draft_install_tasks(array &$install_state) {
return [
'draft_prepare_develop_config_split_directory' => [
'display' => FALSE,
],
];
}
/**
* Prepares configs for the Draft profile.
*/
function draft_prepare_develop_config_split_directory(array &$install_state) {
$config = _draft_read_develop_config_split();
_draft_prepare_develop_config_split_directory($config);
}
/**
* Installs Administration Links Access Filter module.
*/
function draft_update_8101(&$sandbox = NULL) {
\Drupal::service('module_installer')->install(['admin_links_access_filter']);
}
/**
* Installs Configuration Split module and Develop configuration split.
*/
function draft_update_8102(&$sandbox = NULL) {
if (!Drupal::moduleHandler()->moduleExists('config_split')) {
\Drupal::service('module_installer')->install(['config_split']);
$config = _draft_read_develop_config_split();
_draft_prepare_develop_config_split_directory($config);
/** @var \Drupal\Core\Config\CachedStorage $config_storage */
$config_storage = \Drupal::service('config.storage');
$config_storage->write('config_split.config_split.develop', $config);
}
}
/**
* Replace Administration Links Access Filter module with one bundled with Admin
* Toolbar module as of version 1.21.0.
*/
function draft_update_8103(&$sandbox = NULL) {
\Drupal::service('module_installer')->uninstall(['admin_links_access_filter']);
\Drupal::service('module_installer')->install(['admin_toolbar_links_access_filter']);
}
/**
* Reads Develop configuration split configuration data.
*
* @return array
* Develop configuration split configuration data.
*/
function _draft_read_develop_config_split() {
$config_path = drupal_get_path('profile', 'draft') . '/config/install';
$source = new FileStorage($config_path);
return $source->read('config_split.config_split.develop');
}
/**
* Prepares Develop configuration split export directory.
*
* @param array $config
* Develop configuration split configuration data.
*
* @return bool
* TRUE if Develop configuration split export directory exists and is
* writable, FALSE otherwise.
*/
function _draft_prepare_develop_config_split_directory(array $config) {
$directory = \Drupal::root() . '/' . $config['folder'];
return \Drupal::service('file_system')
->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}