Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
c4b313b4
Commit
c4b313b4
authored
Nov 23, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 523999: New Hook: template-before_create
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat
parent
eea9be3a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
Hook.pm
Bugzilla/Hook.pm
+19
-0
Template.pm
Bugzilla/Template.pm
+7
-2
template-before_create.pl
extensions/example/code/template-before_create.pl
+30
-0
No files found.
Bugzilla/Hook.pm
View file @
c4b313b4
...
...
@@ -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
...
...
Bugzilla/Template.pm
View file @
c4b313b4
...
...
@@ -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.
...
...
extensions/example/code/template-before_create.pl
0 → 100644
View file @
c4b313b4
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Example Plugin.
#
# The Initial Developer of the Original Code is ITA Software.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Max Kanat-Alexander <mkanat@bugzilla.org>
use
strict
;
use
warnings
;
use
Bugzilla
;
my
$config
=
Bugzilla
->
hook_args
->
{
'config'
};
# This will be accessible as "example_global_variable" in every
# template in Bugzilla. See Bugzilla/Template.pm's create() function
# for more things that you can set.
$config
->
{
VARIABLES
}
->
{
example_global_variable
}
=
sub
{
return
'value'
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment