]> 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:56 +0000 (15:57 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Wed, 1 Sep 2010 22:57:56 +0000 (15:57 -0700)
operate on any new objects
r=mkanat, a=mkanat

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

index ad9eb01756143e2e8b0fb960ada9e280a772c56f..4ec6b3e4a2c01e19105084d343ca48924f03ffc0 100644 (file)
@@ -208,8 +208,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.
@@ -683,6 +682,27 @@ The value being set on the object.
 
 =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 b1be76635201a05b8140675fa4d4871486df597b..71ced8e9d2ea9ed751eab03d54dba8aeb71146f0 100644 (file)
@@ -487,7 +487,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 d8e4228c05f5e6b76764f1636f434e9b81be597b..60096692e730bd9385d0ce7146e21905b0e92fea 100644 (file)
@@ -359,6 +359,15 @@ sub object_before_set {
     }
 }
 
+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) = @_;