-
Notifications
You must be signed in to change notification settings - Fork 0
/
revision_tree.install
38 lines (33 loc) · 1.36 KB
/
revision_tree.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
<?php
/**
* @file
* Install, update, and uninstall functions for the revision_tree module.
*/
/**
* Implements hook_module_preinstall().
*/
function revision_tree_module_preinstall($module) {
if ($module !== 'revision_tree') {
return;
}
// Clear plugin manager caches so the new 'revision_reference' field type is
// available below.
\Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
/** @var \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager */
$workspace_manager = \Drupal::service('workspaces.manager');
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
foreach ($entity_definition_update_manager->getEntityTypes() as $entity_type) {
if ($entity_type->isRevisionable()) {
$revision_metadata_keys = $entity_type->get('revision_metadata_keys');
if (!isset($revision_metadata_keys['revision_parent'])) {
$revision_metadata_keys['revision_parent'] = 'revision_parent';
$revision_metadata_keys['revision_merge_parent'] = 'revision_merge_parent';
if ($workspace_manager->isEntityTypeSupported($entity_type)) {
$revision_metadata_keys['workspace'] = 'workspace';
}
$entity_type->set('revision_metadata_keys', $revision_metadata_keys);
$entity_definition_update_manager->updateEntityType($entity_type);
}
}
}
}