summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Hook.pm19
-rw-r--r--Bugzilla/Template.pm9
2 files changed, 26 insertions, 2 deletions
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index b922559b5..dc1cd6be1 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -786,6 +786,25 @@ to the user. (F<sanitycheck.cgi>'s C<Status>)
=back
+=head2 template-before_create
+
+This hook allows you to modify the configuration of L<Bugzilla::Template>
+objects before they are created. For example, you could add a new
+global template variable this way.
+
+Params:
+
+=over
+
+=item C<config>
+
+A hashref--the configuration that will be passed to L<Template/new>.
+See L<http://template-toolkit.org/docs/modules/Template.html#section_CONFIGURATION_SUMMARY>
+for information on how this configuration variable is structured (or just
+look at the code for C<create> in L<Bugzilla::Template>.)
+
+=back
+
=head2 template-before_process
This hook allows you to define additional variables that will be available to
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 17429a2e2..b61d28bc7 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -36,6 +36,7 @@ use strict;
use Bugzilla::Bug;
use Bugzilla::Constants;
+use Bugzilla::Hook;
use Bugzilla::Install::Requirements;
use Bugzilla::Install::Util qw(install_string template_include_path
include_languages);
@@ -470,7 +471,7 @@ sub create {
# IMPORTANT - If you make any configuration changes here, make sure to
# make them in t/004.template.t and checksetup.pl.
- return $class->new({
+ my $config = {
# Colon-separated list of directories containing templates.
INCLUDE_PATH => [\&getTemplateIncludePath],
@@ -797,8 +798,12 @@ sub create {
return \@optional;
},
},
+ };
- }) || die("Template creation failed: " . $class->error());
+ Bugzilla::Hook::process('template-before_create', { config => $config });
+ my $template = $class->new($config)
+ || die("Template creation failed: " . $class->error());
+ return $template;
}
# Used as part of the two subroutines below.