-
Notifications
You must be signed in to change notification settings - Fork 19
/
localgov.install
97 lines (85 loc) · 3.13 KB
/
localgov.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
<?php
/**
* @file
* Install functions for the LocalGovInstall installation profile.
*/
use Drupal\views\Entity\View;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function localgov_install() {
$config_factory = \Drupal::configFactory();
// Disable the frontpage view.
$frontpage_view = View::load('frontpage');
$frontpage_view->setStatus(FALSE)->save();
// Set front page to /user.
// This is so there is a default accessible front page on first install.
$system_site_config = $config_factory->getEditable('system.site');
$system_site_config->set('page.front', '/user')->save();
// Enable entity_usage for media by default.
$entity_usage_config = $config_factory->getEditable('entity_usage.settings');
$local_task_enabled_entity_types = $entity_usage_config->get('local_task_enabled_entity_types');
if (!in_array('media', $local_task_enabled_entity_types, TRUE)) {
$local_task_enabled_entity_types[] = 'media';
$entity_usage_config->set('local_task_enabled_entity_types', $local_task_enabled_entity_types);
$entity_usage_config->save(TRUE);
}
}
/**
* Run the potentially skipped search_api_update_8107() safely.
*/
function localgov_update_8201() {
// Superseded by search_api_update_8110().
//
// Sites that have run this update, will get updated by 8110.
// Sites that have not run this update will also get 8110 and shouldn't risk
// running this version after search_api_update_8110.
}
/**
* Enable stable9 theme if localgov_base theme is enabled.
*/
function localgov_update_9501() {
if (\Drupal::service('theme_handler')->themeExists('localgov_base')) {
\Drupal::service('theme_installer')->install(['stable9']);
}
}
/**
* Update default date formats to GDS if they haven't been changed.
*/
function localgov_update_9502() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('core.date_format.long');
if ($config->get('pattern') == 'l j F Y - g:ia') {
$config->set('pattern', 'l j F Y \a\t g:ia');
$config->save(TRUE);
}
$config = $config_factory->getEditable('core.date_format.medium');
if ($config->get('pattern') == 'D, d/m/Y - g:ia') {
$config->set('pattern', 'D d/m/Y g:ia');
$config->save(TRUE);
}
$config = $config_factory->getEditable('core.date_format.short');
if ($config->get('pattern') == 'd/m/Y - g:ia') {
$config->set('pattern', 'd/m/Y g:ia');
$config->save(TRUE);
}
}
/**
* Update existing sites to use entity_usage for media.
*/
function localgov_update_9503() {
if (\Drupal::service('module_handler')->moduleExists('entity_usage')) {
$config_factory = \Drupal::configFactory();
$entity_usage_config = $config_factory->getEditable('entity_usage.settings');
$local_task_enabled_entity_types = $entity_usage_config->get('local_task_enabled_entity_types');
if (!in_array('media', $local_task_enabled_entity_types, TRUE)) {
$local_task_enabled_entity_types[] = 'media';
$entity_usage_config->set('local_task_enabled_entity_types', $local_task_enabled_entity_types);
$entity_usage_config->save(TRUE);
}
}
}