-
Notifications
You must be signed in to change notification settings - Fork 48
Implementation of User-level Actions #382
Copy link
Copy link
Closed
Labels
Description
Although on the basic level models can perform "CRUD" operations (create, read, update and delete), in reality there are many other actions.
Currently you have to create method inside a model, but it's hard for the other components to discover which methods are safe to execute.
I propose we implement hook getActions that would return array of special action objects. So your model Package could be like this:
$this->addHook('getActions', function($m) {
return [
'delivered' => new Action("Signed for Delivery", function($m){
return $m->save('delivered', true);
})
]
});
Second argument is optional and if not specified then $m->delivered() is called. Class Action could be initially quite simple, but then we can add all sorts of properties to it - is at a dangerous action? What arguments are required? etc.
This action would be safe to exported through UI or API frameworks as a button or a POST end-point.
Reactions are currently unavailable