Offer the possibility to override internal formatter objects from plugins

This commit is contained in:
Frederic Guillot
2016-12-20 20:06:39 -05:00
parent a957195952
commit ae708a712a
28 changed files with 200 additions and 72 deletions

View File

@@ -40,3 +40,34 @@ You can still use the original template using the "kanboard:" prefix:
```php
<?= $this->render('kanboard:header') ?>
```
Formatter Overrides
-------------------
Here an example to override formatter objects in Kanboard:
```php
class MyFormatter extends UserAutoCompleteFormatter {
public function format()
{
$users = parent::format();
foreach ($users as &$user) {
$user['label'] = 'something'; // Do something useful here
}
return $users;
}
}
class Plugin extends Base
{
public function initialize()
{
$this->container['userAutoCompleteFormatter'] = $this->container->factory(function ($c) {
return new MyFormatter($c);
});
}
}
```