5 class Workflow extends \Rsi\Fred\Component{
17 if(!array_key_exists($id,$this->workflows))
throw new \Exception(
"Unknown workflow '$id'");
18 return $this->workflows[$id];
28 public function createItem($workflow,$id,$data = null,$status =
'start'){
29 throw new \Exception(
'Not implemented');
45 return $id && $this->
component(
'lock')->request($this->_lockItem,$id);
53 return $id && $this->
component(
'lock')->release($this->_lockItem,$id);
101 public function push($id,$data = null){
114 protected function shift($lock =
false){
122 if($timeout) $timout = time() + $timeout;
124 while((!$timeout || ($timeout < time())) && ($id = $this->
shift(
true)))
try{
125 $log->debug(
"Executing workflow item '$id'",__FILE__,__LINE__);
126 if(($result = $this->
loadItem($id)->
execute()) !==
false) $log->debug(
"Workflow item '$id' result = '$result'",__FILE__,__LINE__);
129 $log->error(
"Timeout expired for workflow item '$id', but no action for status '$status'",__FILE__,__LINE__);
134 $log->emergency(
"Error while executing workflow item '$id': " . $e->getMessage(),$e->getFile(),$e->getLine());
loadItem($id)
Load an existing workflow item.
setItemStatus($id, $status, $remarks=null)
Set the status for an item.
push($id, $data=null)
Push an item into the queue (reschedule to execute as soon as possible).
createItem($workflow, $id, $data=null, $status='start')
Create a new workflow item.
lockItem($id)
Request a lock on a workflow item.
getItemStatus($id)
Get current status for an item.
unlockItem($id)
Release a lock on a workflow item.
execute($timeout=null)
Process the queue.
workflow($id)
Get workflow data.
pause($id)
Pause an item (remove from queue).
getItemData($id)
Get all data for an item.
getItemStatuses($id)
Get all possible (authorized) change statuses from the current status.
component($name)
Get a component (local or default).
setItemData($id, $data)
Set (add) data for an item.
shift($lock=false)
Shift the first item from the queue.