public function StateManager::removeStorageFields in Field Encryption 3.0.x
Removes storage base fields if possible.
File
- src/
StateManager.php, line 157
Class
- StateManager
- Manages state for the module.
Namespace
Drupal\field_encryptCode
public function removeStorageFields() {
$queue = $this->queueFactory
->get('field_encrypt_update_entity_encryption');
// We can't remove the field if there are queue items to process because if
// there is data we'll destroy it.
if ($queue
->numberOfItems() > 0) {
return;
}
$old_entity_types = $this->state
->get('field_encrypt.entity_types', []);
$new_entity_types = $this
->getEntityTypes();
if ($old_entity_types === $new_entity_types) {
// No changes to make. Early return to do nothing and preserve caches.
return;
}
$this->state
->set('field_encrypt.entity_types', $new_entity_types);
// @see field_encrypt.module
$this->moduleHandler
->resetImplementations();
foreach (array_diff($old_entity_types, $new_entity_types) as $type) {
$field = $this->entityDefinitionUpdateManager
->getFieldStorageDefinition(ProcessEntities::ENCRYPTED_FIELD_STORAGE_NAME, $type);
if ($field) {
$this->entityDefinitionUpdateManager
->uninstallFieldStorageDefinition($field);
}
}
}