// Suppose that you want to alter original behavior/class, but don't want to create a new class (with new name), because this will require you to alter options as well.
// Instead, you want just to set up options at design time and provide altered behavior at run-time.
// For example, when you post bug to Mantis, a issue title is composed.
// EurekaLog does not provide way to alter it, because it's used to identify tickets.
// You may want to alter it (say, by appending more info, so title becomes more descriptive).
// Note: please note that this is not recommended way to work with tickets in Mantis.
// We suggest you to create custom fields for your project (this is done in Mantis configuration).
// Fill custom fields with information (this is done in EurekaLog configuration).
// And show some of these fields in list of tickets (this is done in Mantis configuration).
// That way you will archive the desired effect (to see more info about each ticket in list),
// but also additionally gain some benefits: you will be able to sort/filter by custom fields,
// you will not break default EurekaLog tickets identification.
// Anyway, here is how you can do that:
uses
EConsts,
ESend,
ESendAPIMantis;
type
// Trick: use the same class name as original class
// You'll have to append unit name to class ident to avoid compiler confusion
// With this trick you don't have to change options.
// You can just set options at design-time.
// The important part here is to register your class first,
// which is archived by using registering function with "First" suffix (see below).
TELTrackerMantisSender = class(ESendAPIMantis.TELTrackerMantisSender)
protected
function ComposeTitle: String; override;
end;
// This is a default implementation of the method,
// you can replace it with arbitrary code
function TELTrackerMantisSender.ComposeTitle: String;
begin
if BugAppVersion <> '' then
Result := Format('%s (Bug %s; v%s)', [BugType, BugID, BugAppVersion])
else
Result := Format('%s (Bug %s)', [BugType, BugID]);
Log(Format('Title = ''%s''', [Result]));
end;
initialization
// Register send class to be the first in the list.
// Default class (by EurekaLog) will be listed later.
// Any search for class by name will find our class, because it's listed first
RegisterSenderFirst(TELTrackerMantisSender);
end.
Comments