forked from markaspot/service_request
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_request.install
46 lines (41 loc) · 1.38 KB
/
service_request.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
<?php
/**
* @file
* Install file for service_request.
*/
/**
* Implements hook_install().
*
* We don't want users to be able to delete our locked_content_type content
* type. So therefore we have to tell Drupal that this is the case. This
* can't be done in the content type's configuration YAML file, so we have to
* do it in code, here.
*
* @ingroup service_request
*/
function service_request_install() {
// Do not allow the locked content type to be deleted.
$locked = Drupal::state()->get('node.type.locked');
$locked['locked_content_type'] = 'locked_content_type';
Drupal::state()->set('node.type.locked', $locked);
}
/**
* Implements hook_uninstall().
*
* Our content types will live on in the Drupal installation, even after this
* module is uninstalled. This is a good thing, since it allows the user to
* make decisions about their fate. Therefore we should give the user the
* option of deleting them.
*
* Since we told Drupal that our locked_content_type is locked, we now have
* to tell it to unlock.
*
* @ingroup service_request
*/
function service_request_uninstall() {
// Allow locked_content_type to be deleted.
$locked = Drupal::state()->get('node.type.locked');
unset($locked['locked_content_type']);
Drupal::state()->set('node.type.locked', $locked);
\Drupal::configFactory()->getEditable('node.settings')->set('use_admin_theme', TRUE)->save(TRUE);
}