Add doc for plugin events
This commit is contained in:
27
doc/plugin-events.markdown
Normal file
27
doc/plugin-events.markdown
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
Using Events
|
||||||
|
============
|
||||||
|
|
||||||
|
Kanboard use internally the [Symfony EventDispatcher component](https://symfony.com/doc/2.3/components/event_dispatcher/index.html) to manage internal events.
|
||||||
|
|
||||||
|
Event Listening
|
||||||
|
---------------
|
||||||
|
|
||||||
|
```php
|
||||||
|
$this->on('app.bootstrap', function($container) {
|
||||||
|
// Do something
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
- The first argument is the event name (string)
|
||||||
|
- The second argument is a PHP callable function (closure or class method)
|
||||||
|
|
||||||
|
Adding a new event
|
||||||
|
------------------
|
||||||
|
|
||||||
|
To add a new event, you have to call the method `register()` of the class `Kanboard\Core\Event\EventManager`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$this->eventManager->register('my.event.name', 'My new event description');
|
||||||
|
```
|
||||||
|
|
||||||
|
These events can be used by other components of Kanboard like automatic actions.
|
||||||
@@ -124,17 +124,3 @@ $this->container['hourlyRate']->getAll();
|
|||||||
```
|
```
|
||||||
|
|
||||||
Keys of the containers are unique across the application. If you override an existing class, you will change the default behavior.
|
Keys of the containers are unique across the application. If you override an existing class, you will change the default behavior.
|
||||||
|
|
||||||
Event Listening
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Kanboard use internal events and your plugin can listen and perform actions on these events.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$this->on('app.bootstrap', function($container) {
|
|
||||||
// Do something
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
- The first argument is the event name
|
|
||||||
- The second argument is a PHP callable function (closure or class method)
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Plugin creators should specify explicitly the compatible versions of Kanboard. I
|
|||||||
|
|
||||||
- [Creating your plugin](plugin-registration.markdown)
|
- [Creating your plugin](plugin-registration.markdown)
|
||||||
- [Using plugin hooks](plugin-hooks.markdown)
|
- [Using plugin hooks](plugin-hooks.markdown)
|
||||||
|
- [Events](plugin-events.markdown)
|
||||||
- [Override default application behaviors](plugin-overrides.markdown)
|
- [Override default application behaviors](plugin-overrides.markdown)
|
||||||
- [Add schema migrations for plugins](plugin-schema-migrations.markdown)
|
- [Add schema migrations for plugins](plugin-schema-migrations.markdown)
|
||||||
- [Custom routes](plugin-routes.markdown)
|
- [Custom routes](plugin-routes.markdown)
|
||||||
|
|||||||
Reference in New Issue
Block a user