summaryrefslogtreecommitdiff
path: root/doc/en_US/plugin-helpers.markdown
blob: d65467f85c6d73cbc0ef99a5d49f85a34681a49f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Registering new helpers
=======================

Helper skeleton:

```php
<?php

namespace Kanboard\Plugin\MyPlugin\Helper;

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();
```