-
Notifications
You must be signed in to change notification settings - Fork 2
/
tombstones.module
56 lines (49 loc) · 1.43 KB
/
tombstones.module
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
* Contains tombstones.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Implements hook_help().
*/
function tombstones_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the tombstones module.
case 'help.page.tombstones':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Drupal module for creating Tombstone nodes to replace deleted content.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function tombstones_theme($existing, $type, $theme, $path) {
return [
'node__tombstone' => [
'template' => 'node--tombstone',
'base hook' => 'node',
],
];
}
/**
* Implements hook_ENTITY_TYPE_predelete().
*/
function tombstones_node_predelete(Drupal\Core\Entity\EntityInterface $entity) {
if (\Drupal::service('tombstones.service')->shouldTombstoneBeCreatedFromHook($entity)) {
\Drupal::service('tombstones.service')->storeTombstonePredeleteMetadata($entity);
}
}
/**
* Implements hook_ENTITY_TYPE_delete().
*/
function tombstones_node_delete(Drupal\Core\Entity\EntityInterface $entity) {
if (\Drupal::service('tombstones.service')->shouldTombstoneBeCreatedFromHook($entity)) {
\Drupal::service('tombstones.service')->createTombstoneForDeletedNode($entity);
}
}