summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Hook.pm31
-rw-r--r--Bugzilla/Template.pm13
2 files changed, 44 insertions, 0 deletions
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index 2cd99c3e7..51bce7fbe 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -649,6 +649,37 @@ to the user. (F<sanitycheck.cgi>'s C<Status>)
=back
+=head2 template-before_process
+
+This hook allows you to define additional variables that will be available to
+the template being processed. You probably want to restrict your hook
+to operating only if a certain file is being loaded (which is why you
+get a C<file> argument below). Otherwise, modifying the C<vars> argument
+will affect every single template in Bugzilla.
+
+Params:
+
+=over
+
+=item C<vars>
+
+The template vars hashref--these are the values that get passed to the
+template. Adding new keys to this hashref will cause those new values
+to also get passed to the template.
+
+=item C<file>
+
+The name of the template being processed. This is relative
+to the main template directory for the language (i.e. for
+F<template/en/default/bug/show.html.tmpl>, this variable will contain
+C<bug/show.html.tmpl>).
+
+=item C<template>
+
+The L<Bugzilla::Template> object that C<process> was called on.
+
+=back
+
=head2 webservice
This hook allows you to add your own modules to the WebService. (See
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index f94cb2e38..2e2ac4b08 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -79,6 +79,19 @@ sub _load_constants {
return \%constants;
}
+# Overload Template::Process in order to add a hook to allow additional
+# variables to be made available by an extension
+sub process {
+ my $self = shift;
+ my ($file, $vars) = @_;
+
+ Bugzilla::Hook::process("template-before_process",
+ { vars => $vars, file => $file,
+ template => $self });
+
+ return $self->SUPER::process(@_);
+}
+
# Returns the path to the templates based on the Accept-Language
# settings of the user and of the available languages
# If no Accept-Language is present it uses the defined default