function workspaces_module_preinstall

Same name in other branches
  1. 9 core/modules/workspaces/workspaces.install \workspaces_module_preinstall()
  2. 10 core/modules/workspaces/workspaces.install \workspaces_module_preinstall()
  3. 11.x core/modules/workspaces/workspaces.install \workspaces_module_preinstall()

Implements hook_module_preinstall().

File

core/modules/workspaces/workspaces.install, line 35

Code

function workspaces_module_preinstall($module) {
    if ($module !== 'workspaces') {
        return;
    }
    
    /** @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) {
        $revision_metadata_keys = $entity_type->get('revision_metadata_keys');
        if ($workspace_manager->isEntityTypeSupported($entity_type)) {
            $entity_type->setRevisionMetadataKey('workspace', 'workspace');
            $entity_definition_update_manager->updateEntityType($entity_type);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.