function file_entity_uninstall in File Entity (fieldable files) 8.2
Same name and namespace in other branches
- 7.3 file_entity.install \file_entity_uninstall()
- 7 file_entity.install \file_entity_uninstall()
- 7.2 file_entity.install \file_entity_uninstall()
Implements hook_uninstall().
File
- ./
file_entity.install, line 102 - Install, update and uninstall functions for the file_entity module.
Code
function file_entity_uninstall() {
// Delete all configurable fields first, otherwise they are being deleted
// in the wrong order.
$field_storages = \Drupal::entityTypeManager()
->getStorage('field_storage_config')
->loadByProperties([
'entity_type' => 'file',
]);
foreach ($field_storages as $field_storage) {
$field_storage
->delete();
}
// Uninstall the file.type field along with the database column.
$update_manager = Drupal::service('entity.definition_update_manager');
$definition = $update_manager
->getFieldStorageDefinition('type', 'file');
$update_manager
->uninstallFieldStorageDefinition($definition);
$entity_type = \Drupal::entityDefinitionUpdateManager()
->getEntityType('file');
$keys = $entity_type
->getKeys();
$keys['bundle'] = '';
$entity_type
->set('entity_keys', $keys);
\Drupal::entityDefinitionUpdateManager()
->updateEntityType($entity_type);
}