1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kanboard_ynh.git synced 2024-09-03 19:36:17 +02:00
kanboard_ynh/sources/doc/plugin-notifications.markdown

61 lines
1.8 KiB
Markdown
Raw Normal View History

2015-10-26 14:58:06 +01:00
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');
```
2015-12-29 01:24:09 +01:00
Your handler can be registered for user or project notification. You don't necessarily need to support both.
2015-10-26 14:58:06 +01:00
When your handler is registered, the end-user can choose to receive the new notification type or not.
Notification Handler
--------------------
2015-12-29 01:24:09 +01:00
Your notification handler must implement the interface `Kanboard\Notification\NotificationInterface`:
2015-10-26 14:58:06 +01:00
```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)