function _multiversion_update_uuid_fields in Multiversion 8
Updates the field type class for UUID fields when the module is un/installed.
3 calls to _multiversion_update_uuid_fields()
- multiversion_install in ./
multiversion.install - Implements hook_install().
- multiversion_uninstall in ./
multiversion.install - Implements hook_uninstall().
- multiversion_update_8111 in ./
multiversion.install - Apply the UUID field updates.
File
- ./
multiversion.install, line 72
Code
function _multiversion_update_uuid_fields() {
\Drupal::service('plugin.manager.field.field_type')
->clearCachedDefinitions();
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$field_map = \Drupal::service('entity_field.manager')
->getFieldMap();
foreach ($field_map as $entity_type_id => $entity_type_field_map) {
foreach ($entity_type_field_map as $field_name => $field_info) {
if ($field_info['type'] === 'uuid') {
$original_storage_definition = $entity_definition_update_manager
->getFieldStorageDefinition($field_name, $entity_type_id);
if ($original_storage_definition instanceof BaseFieldDefinition) {
$field_storage_definition = BaseFieldDefinition::createFromFieldStorageDefinition($original_storage_definition);
$entity_definition_update_manager
->updateFieldStorageDefinition($field_storage_definition);
}
}
}
}
}