Ticket.property.pre change
From Cerb Wiki
Contents |
Overview
The ticket.property.pre change event point allows you to run an event when preperty are about to be changed.
Several official extensions use this event:
- Opportunity Tracking
- Time Tracking Entries
- Translation System
- Audit Log
- Watchers
Plugin Manifest
plugin.xml:
<extensions> ... <!-- Event Listeners --> <extension point="devblocks.listener.event"> <id>example.plugin.listeners</id> <name>[Example] Example Event Listener</name> <class> <file>api/App.php</file> <name>ExampleEventListener</name> </class> <params> <param key="events"> <value> <data key="ticket.property.pre change" /> <!-- Other events you want to track --> </value> </param> </params> </extension> ... </extensions>
See Extension:devblocks.listener.event for more information.
- <extension point="..."> binds a new extension on the event extension point.
- <id> must be unique across all Cerb4 plugins. This is a dot-delimited namespace string. The name is entirely up to you, but the namespace should follow the name of your plugin, and the ID itself should have a hierarchy. If your plugin is named xyzcompany.myplugin then your extension IDs should follow the convention xyzcompany.myplugin.point.name where point.name represents the event and a unique identifier for each particular extension.
- <name> is a human-readable name for your extension. This can be anything you want. There are situations where you'll want to retrieve your extensions name and use it in functionality exposed to the user (e.g. in a dropdown list); and it's a great approach because the name can be quickly retrieved from the manifest (in memory) without running any plugin-level code.
- <file> and <class> tell Devblocks where to find the extension's implementation in the source code. <file> is relative to your plugin's directory.
- <params> allow the manifest to pass information to each implementation of an extension. Each <param> has a key and value attribute. These are static values that are not expected to change. You'll need to implement properties that are configured by the user
- Line 12: key="events" defines we are looking for events.
- Line 13: Value Marks the being of the events we want to trap.
- Line 14: key="ticket.property.pre change" Define the events we want to trap.
Implementation
class ExampleEventListener extends DevblocksEventListenerExtension { const ID = 'example.plugin.listeners'; function __construct($manifest) { parent::__construct($manifest); } /** * @param Model_DevblocksEvent $event */ function handleEvent(Model_DevblocksEvent $event) { switch($event->id) { case 'ticket.property.pre change': // FIXME Need to add pass though parm. // Do something this event just happened. break; // Other case's go here if you have defined more event points. } } }