Swarm 2014.1: User Guide

Modules

New modules are installed by dropping your module code into the modules folder in your Swarm installation. At a minimum they must include a Module.php file.

The jira module is a good example of a simple module in the system:

swarm_install/module/Jira

Influence activity events, emails, etc.

When something occurs in Perforce (change submitted, files shelved, job added/edited) or the system (comment added, review state changed, etc.) that needs to be handled out of band, it is pushed into the queue. A worker will then pull work out of the queue in background processes and publish an event.

Subscribers to the event flesh the item out (fetch the change/job details, for example) and indicate if it should result in an activity entry, email notification, etc. By subscribing to various topics you can modify the text of activity events, change the contents of emails, drop things entirely from activity, etc.

When you subscribe to an event, set your priority to influence how early or late in the process you run. You will likely want to run after most other modules have done their work to flesh out the event but before the activity module processes it. The activity module sets a good example of subscribing to these events:

swarm_install/module/Activity/Module.php

Note that its priority is set to -100. Select a value before that for your own module (for example, 0 would be neutral and -90 would indicate that you are interested in being last).

The activity module listens to all events. However, be more selective. For example, if you are only interested in changes, subscribe to task.change instead of *. Current task types are:

  • task.change

  • task.shelve

  • task.review

  • task.comment

  • task.job

Templates

Override existing view templates using your custom module. Have a look at an example module that demonstrates how to customize the email templates Swarm uses for comment notifications.

Tip

For more information about views, see the Zend/View Quick Start.

View helpers

Set options on existing helpers

It is possible to influence the behavior of existing view helpers by setting options on them; for an example see: swarm_install/module/Application/Module.php

Register new helpers

It is also possible to register new view helpers by placing them within your module's hierarchy, for example, MyModule/src/MyModule/View/Helper/Foo.php. Use the following Swarm view helper for inspiration: swarm_install/module/Activity/src/Activity/View/Helper/Activity.php

Then register your view helper with the view manager via your ModuleConfig: swarm_install/module/Activity/config/module.config.php

0 matching pages