forked from alxp/islandora
-
Notifications
You must be signed in to change notification settings - Fork 119
/
islandora.install
176 lines (162 loc) · 4.92 KB
/
islandora.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/**
* @file
* Install/update hook implementations.
*/
/**
* Adds common namespaces to jsonld.settings.
*/
function islandora_install() {
update_jsonld_included_namespaces();
}
/**
* Delete the 'delete_media' action we used to provide, if it exists.
*
* Use the core 'media_delete_action' instead.
*/
function islandora_update_8001(&$sandbox) {
$action = \Drupal::service('entity_type.manager')->getStorage('action')->load('delete_media');
if ($action) {
$action->delete();
}
}
/**
* Replaces 'entity_bundle' conditions with 'islandora_entity_bundle'.
*
* This prevents plugin naming collisions between islandora and ctools.
*/
function islandora_update_8002(&$sandbox) {
// Find contexts that have the old 'entity_bundle' condition.
$results = \Drupal::entityQuery('context')->condition('conditions.entity_bundle.id', 'entity_bundle')->execute();
if (empty($results)) {
return;
}
// Set each context config to use 'islandora_entity_bundle' instead.
foreach ($results as $result) {
$config = \Drupal::configFactory()->getEditable("context.context.$result");
$condition = $config->get('conditions.entity_bundle');
$condition['id'] = 'islandora_entity_bundle';
$config->set('conditions.islandora_entity_bundle', $condition);
$config->clear('conditions.entity_bundle');
$config->save();
}
// Force drupal to reload the config.
\Drupal::service('plugin.manager.condition')->clearCachedDefinitions();
}
/**
* Deletes the islandora_version_count table.
*
* We never implemented the functionality.
*/
function islandora_update_8003(&$sandbox) {
\Drupal::service('database')
->schema()
->dropTable('islandora_version_count');
}
/**
* Renames migration source keys -> ids.
*/
function islandora_update_8004() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('migrate_plus.migration.islandora__tags');
if ($config) {
if (!$config->get('source.ids')) {
$config->set('source.ids', $config->get('source.keys'));
$config->clear('source.keys');
$config->save(TRUE);
}
}
}
/**
* Makes migrate_tags an array.
*/
function islandora_update_8005() {
$config_factory = \Drupal::configFactory();
$config_factory->getEditable('migrate_plus.migration.islandora__tags')->delete();
$config = $config_factory->getEditable('migrate_plus.migration.islandora_tags');
if ($config) {
if (!is_array($config->get('migration_tags'))) {
$config->set('migration_tags', [$config->get('migration_tags')]);
$config->save(TRUE);
}
if (!$config->get('source.ids')) {
$config->set('source.ids', $config->get('source.keys'));
$config->clear('source.keys');
$config->save(TRUE);
}
}
}
/**
* Adds adds previously hardcoded namespaces to configuration.
*/
function islandora_update_8006() {
update_jsonld_included_namespaces();
}
/**
* Used by install and update_8006 to add namespaces to jsonld.settings.yml.
*/
function update_jsonld_included_namespaces() {
$namespaces = [
[
'prefix' => 'ldp',
'namespace' => 'http://www.w3.org/ns/ldp#',
], [
'prefix' => 'dc11',
'namespace' => 'http://purl.org/dc/elements/1.1/',
], [
'prefix' => 'dcterms',
'namespace' => 'http://purl.org/dc/terms/',
], [
'prefix' => 'nfo',
'namespace' => 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/v1.1/',
], [
'prefix' => 'ebucore',
'namespace' => 'http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#',
], [
'prefix' => 'fedora',
'namespace' => 'http://fedora.info/definitions/v4/repository#',
], [
'prefix' => 'owl',
'namespace' => 'http://www.w3.org/2002/07/owl#',
], [
'prefix' => 'ore',
'namespace' => 'http://www.openarchives.org/ore/terms/',
], [
'prefix' => 'rdf',
'namespace' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
], [
'prefix' => 'rdau',
'namespace' => 'http://rdaregistry.info/Elements/u/',
], [
'prefix' => 'islandora',
'namespace' => 'http://islandora.ca/',
], [
'prefix' => 'pcdm',
'namespace' => 'http://pcdm.org/models#',
], [
'prefix' => 'use',
'namespace' => 'http://pcdm.org/use#',
], [
'prefix' => 'iana',
'namespace' => 'http://www.iana.org/assignments/relation/',
], [
'prefix' => 'premis',
'namespace' => 'http://www.loc.gov/premis/rdf/v1#',
], [
'prefix' => 'premis3',
'namespace' => 'http://www.loc.gov/premis/rdf/v3/',
], [
'prefix' => 'co',
'namespace' => 'http://purl.org/co/',
],
];
$config = \Drupal::configFactory()->getEditable('jsonld.settings');
if ($config && !is_array($config->get('rdf_namespaces'))) {
$config->set('rdf_namespaces', $namespaces);
$config->save(TRUE);
}
else {
\Drupal::logger('islandora')
->warning("Could not find required jsonld.settings to add default RDF namespaces.");
}
}