Commit 70c4b966 authored by acrollet's avatar acrollet

Fixes Issue #2977013: Uninstall leaves mismatched entity and/or field definitions

parent 1514bf66
......@@ -88,31 +88,29 @@ function bee_install() {
*/
function bee_uninstall() {
$node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple();
$entityFieldManager = Drupal::service('entity_field.manager');
foreach ($node_types as $node_type) {
Drupal::configFactory()->getEditable('node.type.' . $node_type->id())->clear('bee')->save();
Drupal::configFactory()->getEditable('field.field.node.' . $node_type->id() . '.field_availability_daily')->delete();
Drupal::configFactory()->getEditable('field.field.node.' . $node_type->id() . '.field_availability_hourly')->delete();
Drupal::configFactory()->getEditable('field.field.node.' . $node_type->id() . '.field_open_hours')->delete();
Drupal::configFactory()->getEditable('field.field.node.' . $node_type->id() . '.field_use_open_hours')->delete();
$field_names = [
'field_availability_daily',
'field_availability_hourly',
'field_open_hours',
'field_use_open_hours',
'field_product',
'field_price',
'field_price_frequency',
];
$fields = $entityFieldManager->getFieldDefinitions('node', $node_type->id());
foreach ($field_names as $field_name) {
if (isset($fields[$field_name])) {
$fields[$field_name]->delete();
}
}
Drupal::configFactory()->getEditable('field.field.node.' . $node_type->id() . '.field_product')->delete();
Drupal::configFactory()->getEditable('field.field.node.' . $node_type->id() . '.field_price')->delete();
Drupal::configFactory()->getEditable('field.field.node.' . $node_type->id() . '.field_price_frequency')->delete();
Drupal::configFactory()->getEditable('node.type.' . $node_type->id())->clear('bee')->save();
}
Drupal::configFactory()->getEditable('field.storage.node.field_availability_daily')->delete();
Drupal::configFactory()->getEditable('field.storage.node.field_availability_hourly')->delete();
Drupal::configFactory()->getEditable('field.storage.node.field_open_hours')->delete();
Drupal::configFactory()->getEditable('field.storage.node.field_use_open_hours')->delete();
Drupal::configFactory()->getEditable('field.storage.node.field_product')->delete();
Drupal::configFactory()->getEditable('field.storage.node.field_price')->delete();
Drupal::configFactory()->getEditable('field.storage.node.field_price_frequency')->delete();
$states = [
'bee_daily_available',
'bee_daily_not_available',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment