mirror of
https://github.com/YunoHost-Apps/kanboard_ynh.git
synced 2024-09-03 19:36:17 +02:00
40 lines
579 B
Markdown
40 lines
579 B
Markdown
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();
|
|
```
|