Add doc for plugin events
This commit is contained in:
parent
913ec9e39f
commit
4c524700af
|
|
@ -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.
|
||||
|
||||
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)
|
||||
- [Using plugin hooks](plugin-hooks.markdown)
|
||||
- [Events](plugin-events.markdown)
|
||||
- [Override default application behaviors](plugin-overrides.markdown)
|
||||
- [Add schema migrations for plugins](plugin-schema-migrations.markdown)
|
||||
- [Custom routes](plugin-routes.markdown)
|
||||
|
|
|
|||
Loading…
Reference in New Issue