diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-04-22 23:38:17 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-04-22 23:38:17 +0000 |
commit | 257a5b8ef52fa6c2a70aa0197cdfb2becf41d12a (patch) | |
tree | 9504b623a2887295a40924dfeec473a1fa3c9925 /modules/field/field.api.php | |
parent | 80c4c5be368ce67b0de8325d676d3bb18e1609e6 (diff) | |
download | brdo-257a5b8ef52fa6c2a70aa0197cdfb2becf41d12a.tar.gz brdo-257a5b8ef52fa6c2a70aa0197cdfb2becf41d12a.tar.bz2 |
- Patch #777098 by jhodgdon: field storage purge hooks are not documented.
Diffstat (limited to 'modules/field/field.api.php')
-rw-r--r-- | modules/field/field.api.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index da84eb23c..443438760 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -1674,6 +1674,69 @@ function hook_field_purge_field_instance($instance) { } /** + * Remove field storage information when a field record is purged. + * + * Called from field_purge_field() to allow the field storage module + * to remove field information when a field is being purged. + * + * @param $field + * The field being purged. + */ +function hook_field_storage_purge_field($field) { + $table_name = _field_sql_storage_tablename($field); + $revision_name = _field_sql_storage_revision_tablename($field); + db_drop_table($table_name); + db_drop_table($revision_name); +} + +/** + * Remove field storage information when a field instance is purged. + * + * Called from field_purge_instance() to allow the field storage module + * to remove field instance information when a field instance is being + * purged. + * + * @param $instance + * The instance being purged. + */ +function hook_field_storage_purge_field_instance($instance) { + db_delete('my_module_field_instance_info') + ->condition('id', $instance['id']) + ->execute(); +} + +/** + * Remove field storage information when field data is purged. + * + * Called from field_purge_data() to allow the field storage + * module to delete field data information. + * + * @param $entity_type + * The type of $entity; e.g. 'node' or 'user'. + * @param $entity + * The pseudo-entity whose field data to delete. + * @param $field + * The (possibly deleted) field whose data is being purged. + * @param $instance + * The deleted field instance whose data is being purged. + */ +function hook_field_storage_purge($entity_type, $entity, $field, $instance) { + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); + $etid = _field_sql_storage_etid($entity_type); + + $table_name = _field_sql_storage_tablename($field); + $revision_name = _field_sql_storage_revision_tablename($field); + db_delete($table_name) + ->condition('etid', $etid) + ->condition('entity_id', $id) + ->execute(); + db_delete($revision_name) + ->condition('etid', $etid) + ->condition('entity_id', $id) + ->execute(); +} + +/** * @} End of "ingroup field_crud" */ |