Closed
Bug 498635
Opened 17 years ago
Closed 14 years ago
hooking format_comment()
Categories
(Bugzilla :: Extensions, enhancement)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: docwhat, Unassigned)
Details
I have an extension that needs to make a change to format_comment().
This can be done one of two ways:
1) Add a hook to format_comment(), perhaps 'bug-format_comment'.
2) Add a global hook so that anything can be monkey patched.
Monkey patches aren't great, but they are very flexible.
At the moment, my code looks like this:
my $original_format_comment = \&Bugzilla::Bug::format_comment;
*Bugzilla::Bug::format_comment = sub {
my $comment = shift;
if ($comment->{type} == CMT_REFERENCED) {
return "*** bug ".$comment->{extra_data} ." references this bug ***";
# TODO: Use get_text() and global/messages.html.tmpl somehow...
#return get_text('bug_referenced', { ref => $comment->{'extra_data'} });
} else {
return $original_format_comment->($comment);
}
};
Either solution would work. Thanks.
Ciao!
Comment 1•16 years ago
|
||
Option #1 is what we'd go with, for now. Eventually there will be a hooks system that allows you to subclass classes or add methods to them, but not now.
FWIW, hooks are usually only likely to be added if the requester supplies a patch.
Severity: normal → enhancement
| Reporter | ||
Comment 2•16 years ago
|
||
(In reply to comment #1)
> FWIW, hooks are usually only likely to be added if the requester supplies a
> patch.
I didn't have a clue about what might be preferred or even if my 2 suggestions are even reasonable. :-)
Updated•16 years ago
|
Component: User Interface → Extensions
Updated•16 years ago
|
Assignee: ui → extensions
Comment 4•14 years ago
|
||
Yeah, I think it is! :-) Thanks, rojanu. :-)
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•