function webform_demo_event_registration_uninstall in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_demo/webform_demo_event_registration/webform_demo_event_registration.install \webform_demo_event_registration_uninstall()
Implements hook_uninstall().
File
- modules/
webform_demo/ webform_demo_event_registration/ webform_demo_event_registration.install, line 41 - Install, update and uninstall functions for the webform demo event registration module.
Code
function webform_demo_event_registration_uninstall() {
// Delete all webform:demo_event_registration nodes.
$entity_ids = \Drupal::entityQuery('node')
->condition('type', 'webform_demo_event')
->condition('webform.target_id', 'demo_event_registration')
->execute();
if ($entity_ids) {
/** @var \Drupal\node\Entity\Node[] $nodes */
$nodes = Node::loadMultiple($entity_ids);
foreach ($nodes as $node) {
$node
->delete();
}
}
// Delete field configuration manually.
$field_names = [
'field_webform_demo_event_date',
'field_webform_entity_limit_total',
];
foreach ($field_names as $field_name) {
$field_config = FieldConfig::loadByName('node', 'webform_demo_event', $field_name);
if ($field_config) {
$field_config
->delete();
}
$field_storage_config = FieldStorageConfig::loadByName('node', $field_name);
if ($field_storage_config) {
$field_storage_config
->delete();
}
}
}