63
=head1 NAME
63
=head1 NAME
65
Bugzilla::Hook - Extendible extension hooks for Bugzilla code
65
Bugzilla::Hook - Extendable extension hooks for Bugzilla code
67
=head1 SYNOPSIS
67
=head1 SYNOPSIS
193
database when run.
193
database when run.
199
This hook allows you to add your own modules to the WebService. (See
200
L<Bugzilla::WebService>.)
208
A hashref that you can specify the names of your modules and what Perl
209
module handles the functions for that module. (This is actually sent to
210
L<SOAP::Lite/dispatch_with>. You can see how that's used in F<xmlrpc.cgi>.)
212
The Perl module name must start with C<extensions::yourextension::lib::>
213
(replace C<yourextension> with the name of your extension). The C<package>
214
declaration inside that module must also start with
215
C<extensions::yourextension::lib::> in that module's code.
219
$dispatch->{Example} = "extensions::example::lib::Example";
221
And then you'd have a module F<extensions/example/lib/Example.pm>
223
It's recommended that all the keys you put in C<dispatch> start with the
224
name of your extension, so that you don't conflict with the standard Bugzilla
225
WebService functions (and so that you also don't conflict with other
21
use Bugzilla;
21
use Bugzilla;
22
use Bugzilla::Constants;
22
use Bugzilla::Constants;
24
# Use an eval here so that runtests.pl accepts this script even if SOAP-Lite
25
# Use an eval here so that runtests.pl accepts this script even if SOAP-Lite
25
# is not installed.
26
# is not installed.
30
Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE);
31
Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE);
34
Bugzilla::Hook::process('webservice', { dispatch => \%hook_dispatch });
35
local @INC = (bz_locations()->{extensionsdir}, @INC);
32
my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
37
my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
33
->dispatch_with({'Bugzilla' => 'Bugzilla::WebService::Bugzilla',
38
->dispatch_with({'Bugzilla' => 'Bugzilla::WebService::Bugzilla',
34
'Bug' => 'Bugzilla::WebService::Bug',
39
'Bug' => 'Bugzilla::WebService::Bug',
35
'User' => 'Bugzilla::WebService::User',
40
'User' => 'Bugzilla::WebService::User',
36
'Product' => 'Bugzilla::WebService::Product',
41
'Product' => 'Bugzilla::WebService::Product',
38
->on_action(\&Bugzilla::WebService::handle_login)
44
->on_action(\&Bugzilla::WebService::handle_login)
39
->handle;
45
->handle;