function field_attach_delete_bundle
Notify field.module the a bundle was deleted.
This deletes the data for the field instances as well as the field instances themselves. This function actually just marks the data and field instances and deleted, leaving the garbage collection for a separate process, because it is not always possible to delete this much data in a single page request (particularly since for some field types, the deletion is more than just a simple DELETE query).
Parameters
$entity_type: The entity type to which the bundle is bound.
$bundle: The bundle to delete.
Related topics
7 calls to field_attach_delete_bundle()
- comment_node_type_delete in modules/
comment/ comment.module - Implements hook_node_type_delete().
- comment_uninstall in modules/
comment/ comment.install - Implements hook_uninstall().
- EntityFieldQueryTestCase::testEntityFieldQuery in modules/
simpletest/ tests/ entity_query.test - Tests EntityFieldQuery.
- field_test_delete_bundle in modules/
field/ tests/ field_test.entity.inc - Deletes a bundle for test_entity objects.
- node_type_delete in modules/
node/ node.module - Deletes a node type from the database.
File
-
modules/
field/ field.attach.inc, line 1394
Code
function field_attach_delete_bundle($entity_type, $bundle) {
// First, delete the instances themselves. field_read_instances() must be
// used here since field_info_instances() does not return instances for
// disabled entity types or bundles.
$instances = field_read_instances(array(
'entity_type' => $entity_type,
'bundle' => $bundle,
), array(
'include_inactive' => 1,
));
foreach ($instances as $instance) {
field_delete_instance($instance);
}
// Clear the cache.
field_cache_clear();
// Clear bundle display settings.
variable_del('field_bundle_settings_' . $entity_type . '__' . $bundle);
// Let other modules act on deleting the bundle.
module_invoke_all('field_attach_delete_bundle', $entity_type, $bundle, $instances);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.