-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannotations.install
More file actions
42 lines (38 loc) · 1.13 KB
/
Copy pathannotations.install
File metadata and controls
42 lines (38 loc) · 1.13 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
<?php
/**
* @file
* Install and uninstall hooks for the Annotations module.
*/
declare(strict_types=1);
/**
* Implements hook_uninstall().
*
* REMOVE THIS AFTER SUITABLE LEVEL OF DEV?
*
* Drops annotation entity tables explicitly. In a healthy install Drupal's
* entity storage handler handles this automatically, but an explicit drop here
* guards against the case where the entity class is unloadable at uninstall
* time (e.g. mid-development with a broken class definition), which would
* otherwise leave orphaned tables behind.
*
* Note: ContentUninstallValidator runs before this hook and will block
* uninstall if annotation entities exist. Delete annotation content first:
*
* @code
* $storage = \Drupal::entityTypeManager()->getStorage('annotation');
* $storage->delete($storage->loadMultiple());
* @endcode
*/
function annotations_uninstall(): void {
$schema = \Drupal::database()->schema();
foreach ([
'annotation_field_revision',
'annotation_revision',
'annotation_field_data',
'annotation',
] as $table) {
if ($schema->tableExists($table)) {
$schema->dropTable($table);
}
}
}