function WorkspacesHooks::modulePreinstall

Implements hook_module_preinstall().

File

core/modules/workspaces/src/Hook/WorkspacesHooks.php, line 44

Class

WorkspacesHooks
Hook implementations for workspaces.

Namespace

Drupal\workspaces\Hook

Code

public function modulePreinstall($module) {
    if ($module !== 'workspaces') {
        return;
    }
    
    /** @var \Drupal\workspaces\WorkspaceInformationInterface $workspace_info */
    $workspace_info = \Drupal::service('workspaces.information');
    $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
    foreach ($entity_definition_update_manager->getEntityTypes() as $entity_type) {
        if ($workspace_info->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.