-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdmsync.install
More file actions
56 lines (47 loc) · 1.45 KB
/
dmsync.install
File metadata and controls
56 lines (47 loc) · 1.45 KB
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
<?php
/**
* @file
* Install file for dmsync.
*/
/**
* Implements hook_install().
*/
function dmsync_install() {
/* lock content type from deletion */
$content_types = array('dm_user', 'dm_publication', 'dm_author', 'dm_education', 'dm_research', 'dm_award');
$locked = Drupal::state()->get('node.type.locked');
foreach ($content_types as $type) {
$locked[$type] = $type;
}
Drupal::state()->set('node.type.locked', $locked);
}
/**
* Implements hook_uninstall().
*/
function dmsync_uninstall() {
/* unlock content type */
$content_types = array('dm_user', 'dm_publication', 'dm_author', 'dm_education', 'dm_research', 'dm_award');
$locked = Drupal::state()->get('node.type.locked');
foreach ($content_types as $type) {
unset($locked[$type]);
}
Drupal::state()->set('node.type.locked', $locked);
foreach ($content_types as $type) {
/* delete node data */
$nodes = \Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties(array('type' => $type));
foreach ($nodes as $node) {
$node->delete();
}
/* delete node type */
$content_type = \Drupal::entityManager()->getStorage('node_type')->load($type);
if ($content_type)
$content_type->delete();
}
/* delete configuration */
\Drupal::service('config.factory')->getEditable('dmsync.configuration')->delete();
/* delete queue */
$queue = \Drupal::queue('dmsync_queue');
if ($queue) $queue->deleteQueue();
}