Helper refactoring
This commit is contained in:
40
doc/plugin-helpers.markdown
Normal file
40
doc/plugin-helpers.markdown
Normal file
@@ -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();
|
||||
```
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user