diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-03 19:25:53 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-03 19:25:53 -0500 |
commit | 4c524700af72a01c4ffe9949a9005b41dc7e7e4d (patch) | |
tree | 1646877a23b9424258df88f867ef443f42c2119f /doc | |
parent | 913ec9e39ff6326d0d3e4bea92dc6d06b3d2d1bd (diff) |
Add doc for plugin events
Diffstat (limited to 'doc')
-rw-r--r-- | doc/plugin-events.markdown | 27 | ||||
-rw-r--r-- | doc/plugin-registration.markdown | 14 | ||||
-rw-r--r-- | doc/plugins.markdown | 1 |
3 files changed, 28 insertions, 14 deletions
diff --git a/doc/plugin-events.markdown b/doc/plugin-events.markdown new file mode 100644 index 00000000..f4db8ff3 --- /dev/null +++ b/doc/plugin-events.markdown @@ -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. diff --git a/doc/plugin-registration.markdown b/doc/plugin-registration.markdown index 37e71f9a..d15f98e1 100644 --- a/doc/plugin-registration.markdown +++ b/doc/plugin-registration.markdown @@ -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) diff --git a/doc/plugins.markdown b/doc/plugins.markdown index 0b7316a9..791fe3bd 100644 --- a/doc/plugins.markdown +++ b/doc/plugins.markdown @@ -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) |