summaryrefslogtreecommitdiff
path: root/doc/plugin-notifications.markdown
blob: 83fdb5e339f2782bda8a9a88d3592b5919a0daf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Add Notification Types with Plugins
===================================

You can send notifications to almost any system by adding a new type.
There are two kinds of notifications: project and user.

- Project: Notifications configured at the project level
- User: Notifications sent individually and configured at the user profile

Register a new notification type
--------------------------------

In your plugin registration file call the method `setType()`:

```php
$this->userNotificationType->setType('irc', t('IRC'), '\Kanboard\Plugin\IRC\Notification\IrcHandler');
$this->projectNotificationType->setType('irc', t('IRC'), '\Kanboard\Plugin\IRC\Notification\IrcHandler');
```

Your handler can be registered for user or project notification. You don't necessary need to support both.

When your handler is registered, the end-user can choose to receive the new notification type or not.

Notification Handler
--------------------

Your notification handler must implements the interface `Kanboard\Notification\NotificationInterface`:

```php
interface NotificationInterface
{
    /**
     * Send notification to a user
     *
     * @access public
     * @param  array     $user
     * @param  string    $event_name
     * @param  array     $event_data
     */
    public function notifyUser(array $user, $event_name, array $event_data);

    /**
     * Send notification to a project
     *
     * @access public
     * @param  array     $project
     * @param  string    $event_name
     * @param  array     $event_data
     */
    public function notifyProject(array $project, $event_name, array $event_data);
}
```

Example of notification plugins
-------------------------------

- [Slack](https://github.com/kanboard/plugin-slack)
- [Hipchat](https://github.com/kanboard/plugin-hipchat)
- [Jabber](https://github.com/kanboard/plugin-jabber)