summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-03-04 20:10:34 -0500
committerFrederic Guillot <fred@kanboard.net>2016-03-04 20:10:34 -0500
commit8f3e2b2e5c62a6130f6c8867ab335fb4c1a32c5c (patch)
treece28cdc2dba9c31560ef753ac1b4dc39d567b7a6 /doc
parentf32507d423c46e8e9612b5239728e6c617e4cbcb (diff)
Helper refactoring
Diffstat (limited to 'doc')
-rw-r--r--doc/plugin-helpers.markdown40
-rw-r--r--doc/plugins.markdown1
2 files changed, 41 insertions, 0 deletions
diff --git a/doc/plugin-helpers.markdown b/doc/plugin-helpers.markdown
new file mode 100644
index 00000000..8cc6b42a
--- /dev/null
+++ b/doc/plugin-helpers.markdown
@@ -0,0 +1,40 @@
+Registering new helpers
+=======================
+
+Helper skeleton:
+
+```php
+<?php
+
+namespace Kanboard\Plugin\MyPlugin\Helper\MyHelper;
+
+use Kanboard\Core\Base;
+
+class MyHelper extends Base
+{
+ public function doSomething()
+ {
+ return 'foobar';
+ }
+}
+```
+
+Register your helper class:
+
+```php
+$this->helper->register('myHelper', '\Kanboard\Plugin\MyPlugin\Helper\MyHelper');
+```
+
+Using your helper from a template:
+
+```php
+<p>
+ <?= $this->myHelper->doSomething() ?>
+</p>
+```
+
+Using your helper from another class:
+
+```php
+$this->helper->myHelper->doSomething();
+```
diff --git a/doc/plugins.markdown b/doc/plugins.markdown
index 55575612..e38c887f 100644
--- a/doc/plugins.markdown
+++ b/doc/plugins.markdown
@@ -13,6 +13,7 @@ Plugin creators should specify explicitly the compatible versions of Kanboard. I
- [Override default application behaviors](plugin-overrides.markdown)
- [Add schema migrations for plugins](plugin-schema-migrations.markdown)
- [Custom routes](plugin-routes.markdown)
+- [Add helpers](plugin-helpers.markdown)
- [Add mail transports](plugin-mail-transports.markdown)
- [Add notification types](plugin-notifications.markdown)
- [Add automatic actions](plugin-automatic-actions.markdown)