-
Notifications
You must be signed in to change notification settings - Fork 1
/
localgov_events.install
75 lines (66 loc) · 2.25 KB
/
localgov_events.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
<?php
/**
* @file
* LocalGov Events install file.
*/
use Drupal\taxonomy\Entity\Term;
/**
* Implements hook_install().
*/
function localgov_events_install($is_syncing) {
// Don't configure the extra fields or config during config sync operations.
if ($is_syncing) {
return;
}
// Configure optional fields.
$directory_page = \Drupal::moduleHandler()->moduleExists('localgov_directories_page');
$directory_venue = \Drupal::moduleHandler()->moduleExists('localgov_directories_venue');
localgov_events_optional_fields_settings($directory_page, $directory_venue);
// Add default event price taxonomy terms.
$prices = [
'Free',
'Paid',
];
foreach ($prices as $price) {
Term::create([
'parent' => [],
'name' => $price,
'vid' => 'localgov_event_price',
])->save();
}
// Install default config for simple_sitemap, as this does not appear to work
// in the config/optional folder.
// Discussed on https://www.drupal.org/project/simple_sitemap/issues/3156080
if (\Drupal::moduleHandler()->moduleExists('simple_sitemap')) {
$entity_manager = \Drupal::service('simple_sitemap.entity_manager');
$entity_manager->setBundleSettings('node', 'localgov_event', [
'index' => TRUE,
'priority' => 0.5,
]);
}
}
/**
* Use new 'Embed' View Mode for Geo if not already altered.
*/
function localgov_events_update_8001() {
// Upgrade to LocalGov Geo copies over default to embed view mode; but removes
// the new label field from the template. Embed on upgrade should behave the
// same as Default did.
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('core.entity_view_display.node.localgov_event.default');
if ($config->get('content.localgov_event_location.settings.view_mode') == 'default') {
$config->set('content.localgov_event_location.settings.view_mode', 'embed');
$config->save(TRUE);
}
}
/**
* Update date format to GDS if it hasn't been changed.
*/
function localgov_events_update_8002() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('core.date_format.localgov_event_date_full');
if ($config->get('pattern') == 'l, jS F Y, g.ia') {
$config->set('pattern', 'l j F Y, g.ia');
$config->save(TRUE);
}
}