Skip to content

Commit 9039cb6

Browse files
committed
Added example from #207
1 parent b11f596 commit 9039cb6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,24 @@ Note that the 'inputs' parameter is writable and is an array. The array may cont
766766

767767
The 'before' function allows modification of the request parameters and can (for instance) be used to implement soft delete behavior.
768768

769+
```php
770+
'before'=>function(&$cmd, &$db, &$tab, &$id, &$in) {
771+
if ($cmd == 'delete') {
772+
$cmd = 'update'; // change command to update
773+
foreach($in as $k => $o) {
774+
$in[$k]->deleted = date('Y-m-d H:i:s', time());
775+
}
776+
}
777+
778+
},
779+
'column_authorizer'=>function($cmd, $db ,$tab, $col) {
780+
return ( ! in_array($col, array('deleted')));
781+
},
782+
'record_filter'=>function($cmd,$db,$tab) {
783+
return array('deleted,is,null');
784+
}
785+
```
786+
769787
## Custom actions
770788

771789
After any operation the 'after' function is called that allows you to do some custom actions.

0 commit comments

Comments
 (0)