function merci_core_delete_instance in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
Deletes the specified instance and handles field cleanup manually in case the instance is of a disabled field.
Parameters
$instance: The field instance info array to be deleted.
1 call to merci_core_delete_instance()
- merci_core_delete_instances in merci_core/
merci_core.module - Deletes any field instance attached to entities of the specified type, regardless of whether or not the field is active.
File
- merci_core/
merci_core.module, line 480
Code
function merci_core_delete_instance($instance) {
if (empty($instance)) {
return;
}
// First activate the instance's field if necessary.
$field_name = $instance['field_name'];
$activated = merci_core_activate_field($field_name);
// Clear the field cache if we just activated the field.
if ($activated) {
field_cache_clear();
}
// Then delete the instance.
field_delete_instance($instance, FALSE);
// Now check to see if there are any other instances of the field left.
$field = field_info_field($field_name);
if (count($field['bundles']) == 0) {
field_delete_field($field_name);
}
elseif ($activated) {
// If there are remaining instances but the field was originally disabled,
// disabled it again now.
$field['active'] = 0;
field_update_field($field);
}
}