]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 587793: Add a new "object_end_of_create" hook so that extensions can
authorChristian Legnitto <clegnitto@mozilla.com>
Wed, 1 Sep 2010 22:57:13 +0000 (15:57 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Wed, 1 Sep 2010 22:57:13 +0000 (15:57 -0700)
operate on any new objects
r=mkanat, a=mkanat

Bugzilla/Hook.pm
Bugzilla/Object.pm
extensions/Example/Extension.pm

index 789ad87401a56240be0788630826ec44aaf2f36e..adcb7ff4be5e4c0f41e9efcf367721f3fa367982 100644 (file)
@@ -210,8 +210,7 @@ Params:
 
 =over
 
-=item C<bug> - The changed bug object, with all fields set to their updated
-values.
+=item C<bug> - The created bug object.
 
 =item C<timestamp> - The timestamp used for all updates in this transaction,
 as a SQL date string.
@@ -821,6 +820,27 @@ or remove standard object columns using this hook.
 
 =back
 
+=head2 object_end_of_create
+
+Called at the end of L<Bugzilla::Object/create>, after all other changes are
+made to the database. This occurs inside a database transaction.
+
+Params:
+
+=over
+
+=item C<class>
+
+The name of the class that C<create> was called on. You can check this 
+like C<< if ($class->isa('Some::Class')) >> in your code, to perform specific
+tasks for only certain classes.
+
+=item C<object>
+
+The created object.
+
+=back
+
 =head2 object_end_of_create_validators
 
 Called at the end of L<Bugzilla::Object/run_create_validators>. You can
index 66dac9422fae18923e117ddf4d99f637ac50fb46..5b8576512a1a96e9358810dac02f03055cbaf6ab 100644 (file)
@@ -508,7 +508,12 @@ sub insert_create_data {
     $dbh->do("INSERT INTO $table (" . join(', ', @field_names)
              . ") VALUES ($qmarks)", undef, @values);
     my $id = $dbh->bz_last_key($table, $class->ID_FIELD);
-    return $class->new($id);
+
+    my $object = $class->new($id);
+
+    Bugzilla::Hook::process('object_end_of_create', { class => $class,
+                                                      object => $object });
+    return $object;
 }
 
 sub get_all {
index 2a6f6946dc4ec6102fca102195bf0de4a7473b37..235c93082ddf5f88c20b7581c696d4266fdee3a7 100644 (file)
@@ -411,6 +411,15 @@ sub object_columns {
     }
 }
 
+sub object_end_of_create {
+    my ($self, $args) = @_;
+    
+    my $class  = $args->{'class'};
+    my $object = $args->{'object'};
+
+    warn "Created a new $class object!";
+}
+
 sub object_end_of_create_validators {
     my ($self, $args) = @_;