]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 396243: Allow extensions (aka plugins) to extend the WebService interface - Patch...
authorlpsolit%gmail.com <>
Thu, 8 May 2008 03:27:26 +0000 (03:27 +0000)
committerlpsolit%gmail.com <>
Thu, 8 May 2008 03:27:26 +0000 (03:27 +0000)
Bugzilla/Hook.pm
xmlrpc.cgi

index 8ce2d4bd1317efa860560c90426307afa94f36c9..90ac16237dba94b5b5f9228ef6faddf6032bef70 100644 (file)
@@ -59,7 +59,7 @@ __END__
 
 =head1 NAME
 
-Bugzilla::Hook - Extendible extension hooks for Bugzilla code
+Bugzilla::Hook - Extendable extension hooks for Bugzilla code
 
 =head1 SYNOPSIS
 
@@ -190,3 +190,36 @@ definitions. F<checksetup.pl> will automatically add these tables to the
 database when run.
 
 =back
+
+=head2 webservice
+
+This hook allows you to add your own modules to the WebService. (See
+L<Bugzilla::WebService>.)
+
+Params:
+
+=over
+
+=item C<dispatch>
+
+A hashref that you can specify the names of your modules and what Perl
+module handles the functions for that module. (This is actually sent to 
+L<SOAP::Lite/dispatch_with>. You can see how that's used in F<xmlrpc.cgi>.)
+
+The Perl module name must start with C<extensions::yourextension::lib::>
+(replace C<yourextension> with the name of your extension). The C<package>
+declaration inside that module must also start with 
+C<extensions::yourextension::lib::> in that module's code.
+
+Example:
+
+  $dispatch->{Example} = "extensions::example::lib::Example";
+
+And then you'd have a module F<extensions/example/lib/Example.pm>
+
+It's recommended that all the keys you put in C<dispatch> start with the
+name of your extension, so that you don't conflict with the standard Bugzilla
+WebService functions (and so that you also don't conflict with other
+plugins).
+
+=back
index c17cab86c3e8ce1a49da9cb9ef076ee272157270..7682b20f547f60cf685774ac96001879819da5a3 100755 (executable)
@@ -20,6 +20,7 @@ use lib qw(.);
 
 use Bugzilla;
 use Bugzilla::Constants;
+use Bugzilla::Hook;
 
 # Use an eval here so that runtests.pl accepts this script even if SOAP-Lite
 # is not installed.
@@ -29,11 +30,16 @@ $@ && ThrowCodeError('soap_not_installed');
 
 Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE);
 
+my %hook_dispatch;
+Bugzilla::Hook::process('webservice', { dispatch => \%hook_dispatch });
+local @INC = (bz_locations()->{extensionsdir}, @INC);
+
 my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
     ->dispatch_with({'Bugzilla' => 'Bugzilla::WebService::Bugzilla',
                      'Bug'      => 'Bugzilla::WebService::Bug',
                      'User'     => 'Bugzilla::WebService::User',
                      'Product'  => 'Bugzilla::WebService::Product',
+                     %hook_dispatch
                     })
     ->on_action(\&Bugzilla::WebService::handle_login)
     ->handle;