diff options
-rw-r--r-- | modules/field/field.api.php | 27 | ||||
-rw-r--r-- | modules/field/field.crud.inc | 2 |
2 files changed, 28 insertions, 1 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 443438760..71c97fe50 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -1050,6 +1050,33 @@ function hook_field_attach_delete_revision($entity_type, $entity) { } /** + * Act on field_purge_data. + * + * This hook is invoked in field_purge_data() and allows modules to act on + * purging data from a single field pseudo-entity. For example, if a module + * relates data in the field with its own data, it may purge its own data + * during this process as well. + * + * @param $entity_type + * The type of $entity; e.g. 'node' or 'user'. + * @param $entity + * The pseudo-entity whose field data is being purged. + * @param $field + * The (possibly deleted) field whose data is being purged. + * @param $instance + * The deleted field instance whose data is being purged. + * + * @see @link field_purge Field API bulk data deletion @endlink + * @see field_purge_data() + */ +function hook_field_attach_purge($entity_type, $entity, $field, $instance) { + // find the corresponding data in mymodule and purge it + if($entity_type == 'node' && $field->field_name == 'my_field_name') { + mymodule_remove_mydata($entity->nid); + } +} + +/** * Act on field_attach_view. * * This hook is invoked after the field module has performed the operation. diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index d63dfdada..8150c975c 100644 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -1040,7 +1040,7 @@ function field_purge_batch($batch_size) { * @param $entity_type * The type of $entity; e.g. 'node' or 'user'. * @param $entity - * The pseudo-entity whose field data to delete. + * The pseudo-entity whose field data is being purged. * @param $field * The (possibly deleted) field whose data is being purged. * @param $instance |