Added example from #207

This commit is contained in:
mevdschee 2017-03-15 17:31:15 +01:00
commit 9039cb66a9

View file

@ -766,6 +766,24 @@ Note that the 'inputs' parameter is writable and is an array. The array may cont
The 'before' function allows modification of the request parameters and can (for instance) be used to implement soft delete behavior. The 'before' function allows modification of the request parameters and can (for instance) be used to implement soft delete behavior.
```php
'before'=>function(&$cmd, &$db, &$tab, &$id, &$in) {
if ($cmd == 'delete') {
$cmd = 'update'; // change command to update
foreach($in as $k => $o) {
$in[$k]->deleted = date('Y-m-d H:i:s', time());
}
}
},
'column_authorizer'=>function($cmd, $db ,$tab, $col) {
return ( ! in_array($col, array('deleted')));
},
'record_filter'=>function($cmd,$db,$tab) {
return array('deleted,is,null');
}
```
## Custom actions ## Custom actions
After any operation the 'after' function is called that allows you to do some custom actions. After any operation the 'after' function is called that allows you to do some custom actions.