summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-04-30 19:24:03 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-04-30 19:24:03 +0000
commit682ad44a506ea21640b9c052e801a7f75ed4bd9a (patch)
treebf98ff7b2bdc8f17a91e14abb27415808487d9dd
parentc3b99228848c136803783a6776a33c11d859ab42 (diff)
downloadbrdo-682ad44a506ea21640b9c052e801a7f75ed4bd9a.tar.gz
brdo-682ad44a506ea21640b9c052e801a7f75ed4bd9a.tar.bz2
#775936 by nvahalik, jhodgdon, fp: Document hook_field_update_forbid().
-rw-r--r--modules/field/field.api.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index 71c97fe50..1f4eca048 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -1792,3 +1792,22 @@ function hook_field_storage_purge($entity_type, $entity, $field, $instance) {
*/
function hook_field_access($op, $field, $entity_type, $entity, $account) {
}
+
+/**
+ * Allows a module to object to a field definition update.
+ *
+ * The module should throw a FieldUpdateForbiddenException to indicate
+ * that the update should not proceed.
+ *
+ * @param $field
+ * The updated field structure that a module is attempting to save.
+ * @param $prior_field
+ * The currently-saved field structure.
+ * @param $has_data
+ * TRUE if the field has data in storage currently.
+ */
+function hook_field_update_forbid($field, $prior_field, $has_data) {
+ if ($has_data && $field['columns'] != $prior_field['columns']) {
+ throw new FieldUpdateForbiddenException("field_sql_storage cannot change the schema for an existing field with data.");
+ }
+}