From 0371acff89b14b9bdcb03e72fd9637e26e6b517c Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 29 Jan 2017 11:07:42 -0500 Subject: Move English documentation to folder en_US --- doc/en_US/plugin-automatic-actions.markdown | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 doc/en_US/plugin-automatic-actions.markdown (limited to 'doc/en_US/plugin-automatic-actions.markdown') diff --git a/doc/en_US/plugin-automatic-actions.markdown b/doc/en_US/plugin-automatic-actions.markdown new file mode 100644 index 00000000..b309fac9 --- /dev/null +++ b/doc/en_US/plugin-automatic-actions.markdown @@ -0,0 +1,60 @@ +Adding Automatic Actions +======================== + +Adding a new automatic action is pretty simple. + +Creating a new action +--------------------- + +Your automatic action must inherit of the class `Kanboard\Action\Base`. +Several abstract methods must be implemented by yourself: + +| Method | Description | +|-------------------------------------|------------------------------------------------------------------| +| `getDescription()` | Description visible in the user interface | +| `getCompatibleEvents()` | Get the list of compatible events | +| `getActionRequiredParameters()` | Get the required parameter for the action (defined by the user) | +| `getEventRequiredParameters()` | Get the required parameter for the event | +| `doAction(array $data)` | Execute the action, must return true on success | +| `hasRequiredCondition(array $data)` | Check if the event data meet the action condition | + +Your automatic action is identified in Kanboard by using the absolute class name with the name space included. + +Adding new events +----------------- + +The list of application events is available in the class `Kanboard\Core\Event\EventManager::getAll()`. +However, if your plugin fires new events, you can register these events like that: + +```php +$this->actionManager->getAction('\Kanboard\Plugin\MyPlugin\MyActionName')->addEvent('my.event', 'My event description'); +``` + +You can extend the list of compatible events of existing actions by using the same method. + +Registering the action +---------------------- + +You have to call the method `register()` from the class `Kanboard\Core\Action\ActionManager`: + +```php +actionManager->register(new TaskRename($this->container)); + } +} +``` + +Example +------- + +- [Automatic Action example](https://github.com/kanboard/plugin-example-automatic-action) -- cgit v1.2.3