Allow to extend automatic actions from plugins

This commit is contained in:
Frederic Guillot
2015-09-22 21:17:50 -04:00
parent b4fe1cd526
commit 9523ff44c0
4 changed files with 88 additions and 4 deletions

View File

@@ -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)