diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-22 21:17:50 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-22 21:17:50 -0400 |
commit | 9523ff44c04bf915e8b819ba8502ea5d20127d17 (patch) | |
tree | dc8da8d21c7b87236d929c1f6986351c1fad440b /doc/plugins.markdown | |
parent | b4fe1cd526e0227b49a399e02052beb1d35abd7f (diff) |
Allow to extend automatic actions from plugins
Diffstat (limited to 'doc/plugins.markdown')
-rw-r--r-- | doc/plugins.markdown | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/doc/plugins.markdown b/doc/plugins.markdown index 1f04374f..1127a636 100644 --- a/doc/plugins.markdown +++ b/doc/plugins.markdown @@ -251,10 +251,47 @@ $this->on('session.bootstrap', function($container) { - The first argument is the event name - The second argument is a PHP callable function (closure or class method) +Extend Automatic Actions +------------------------ + +To define a new automatic action with a plugin, you just need to call the method `extendActions()` from the class `Model\Action`, here an example: + +```php +<?php + +namespace Plugin\AutomaticAction; + +use Core\Plugin\Base; + +class Plugin extends Base +{ + public function initialize() + { + $this->action->extendActions( + '\Plugin\AutomaticAction\Action\SendSlackMessage', // Use absolute namespace + t('Send a message to Slack when the task color change') + ); + } +} +``` + +- The first argument of the method `extendActions()` is the action class with the complete namespace path. **The namespace path must starts with a backslash** otherwise Kanboard will not be able to load your class. +- The second argument is the description of your automatic action. + +The automatic action class must inherits from the class `Action\Base` and implements all abstract methods: + +- `getCompatibleEvents()` +- `getActionRequiredParameters()` +- `getEventRequiredParameters()` +- `doAction(array $data)` +- `hasRequiredCondition(array $data)` + +For more details you should take a look to existing automatic actions or this [plugin example](https://github.com/kanboard/plugin-example-automatic-action). + Extend ACL ---------- -Kanboard use a custom access list for privilege separations. Your extension can add new rules: +Kanboard use an access list for privilege separations. Your extension can add new rules: ```php $this->acl->extend('project_manager_acl', array('mycontroller' => '*')); @@ -365,5 +402,6 @@ Examples of plugins - [Budget planning](https://github.com/kanboard/plugin-budget) - [User timetable](https://github.com/kanboard/plugin-timetable) - [Subtask Forecast](https://github.com/kanboard/plugin-subtask-forecast) -- [Theme plugin sample](https://github.com/kanboard/plugin-example-theme) -- [CSS plugin sample](https://github.com/kanboard/plugin-example-css) +- [Automatic Action example](https://github.com/kanboard/plugin-example-automatic-action) +- [Theme plugin example](https://github.com/kanboard/plugin-example-theme) +- [CSS plugin example](https://github.com/kanboard/plugin-example-css) |