-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapigee_openbank_devportal_kickstart.install
119 lines (106 loc) · 3.54 KB
/
apigee_openbank_devportal_kickstart.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* @file
* Copyright 2019 Google Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* @file
* Install, update and uninstall functions for Apigee Kickstart profile.
*/
use Drupal\Core\Messenger\MessengerInterface;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function apigee_openbank_devportal_kickstart_install() {
// Get profile path.
$src_path = drupal_get_path('profile', 'apigee_openbank_devportal_kickstart') . '/resources/files';
// Get public files directory.
$dest_path = file_default_scheme() . '://';
// Files to copy.
// Not all files are copied. So we list them here individually.
$filesets = [
'' => [
'aditya-vyas-1392552-unsplash.jpg',
'donald-giannatti-671274-unsplash.jpg',
'nasa-43567-unsplash.jpg',
'nasa-43569-unsplash.jpg',
'nasa-89116-unsplash.jpg',
'spacex-1130896-unsplash.jpg',
'spacex-81773-unsplash.jpg',
'terence-burke-1417892-unsplash.jpg',
],
'apidoc_specs/' => [
'petstore.yaml',
],
];
// Copy files in public files directory. Note: Managed files are not desired.
foreach ($filesets as $destination => $files) {
foreach ($files as $file) {
if (file_exists($src_path . '/' . $file)) {
// If the file exists in public://, it should be skipped, as these are
// tied to media entities which hard-code the path/file.
$directory = $dest_path . $destination;
if (!empty($destination)) {
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
}
file_unmanaged_copy($src_path . '/' . $file, $directory . $file);
}
}
}
}
/**
* Implements hook_install_tasks().
*/
function apigee_openbank_devportal_kickstart_install_tasks(&$install_state) {
$tasks = [
'\Drupal\apigee_openbank_devportal_kickstart\Installer\Form\DemoInstallForm' => [
'display_name' => t('Install demo content'),
'type' => 'form',
],
'apigee_openbank_devportal_kickstart_theme_setup' => [
'display_name' => t('Install theme'),
'display' => FALSE,
],
];
return $tasks;
}
/**
* Install the theme.
*
* @param array $install_state
* The install state.
*/
function apigee_openbank_devportal_kickstart_theme_setup(array &$install_state) {
// Clear all status messages generated by modules installed in previous step.
Drupal::messenger()->deleteByType(MessengerInterface::TYPE_STATUS);
// Set apigee_openbank_kickstart as the default theme.
\Drupal::configFactory()
->getEditable('system.theme')
->set('default', 'apigee_openbank_kickstart')
->save();
// Ensure that the install profile's theme is used.
// @see _drupal_maintenance_theme()
\Drupal::service('theme.manager')->resetActiveTheme();
// Enable the admin theme for editing content.
\Drupal::configFactory()
->getEditable('node.settings')
->set('use_admin_theme', TRUE)
->save(TRUE);
}