A simple workflow behavior for Yii ActiveRecord
|
Public Member Functions | |
createSWNode ($node, $workflowId) | |
addWorkflow ($definition, $id) | |
loadWorkflow ($workflowId, $forceReload=false) | |
getNodeDefinition ($node, $defaultWorkflowId=null) | |
getNextNodes ($sourceNode, $workflowId=null) | |
isNextNode ($sourceNode, $targetNode, $workflowId=null) | |
getInitialNode ($workflowId) | |
getAllNodes ($workflowId) | |
Data Fields | |
$preload =array() | |
$workflowNamePrefix ='sw' | |
This is the base class for all workflow source implementations. It provides basic initialization features and a set of methods that must be implemented by workflow source classes.
|
abstract |
Add a workflow to the internal workflow collection. The definition of the workflow to add is provided in the $definition argument as an associative array. This method is used for instance when a workflow definition is provided by a model and not by a php file or another source. If a workflow with the same id is already loaded, it is not over written.
array | $definition | workflow definition |
string | $id | unique id for the workflow to add |
createSWNode | ( | $node, | |
$workflowId | |||
) |
Create and returns a SWNode object. The SWNode returned doesn't have to be defined in a workflow currently loaded.
If $node is a string, it can be a fully qualified node id (e.g workflowId/NodeId) or only a nodeId, but in this case, argument $workflowId must contain the id of the workflow to use.
If $node is a SWNode object, then it is returned with no modification.
|
abstract |
Fetch all nodes belonging to the workflow whose Id is passed as argument.
string | $workflowId | id of the workflow that owns all nodes returned |
|
abstract |
Returns the initial node defined for the workflow whose id is passed as argument. A valid workflow must have one and only one initial status. If it's note the case, workflow can't be loaded.
|
abstract |
Returns an array containing all SWNode object for each status that can be reached from $startStatus. It does not evaluate node constraint but only the fact that a transition exist beteween $startStatus and nodes returned. If no nodes are found, an empty array is returned. An exception is thrown if $startStatus is not found among all worklows available.
|
abstract |
Search for the node passed as argument in the workflow definition. Note that if this node is not found among the currently loaded workflows, this method will try to load the workflow it belongs to.
mixed | node String or SWNode object to look for |
|
abstract |
Checks if there is a transition between the two nodes passed as argument.
mixed | $sourceNode | can be provided as a SWNode object, or as a string that can contain a workflowId or not. |
mixed | $targetNode | target node to test |
|
abstract |
Loads the workflow whose id is passed as argument from the source. If it was already loaded, then it is not reloaded unles $forceReload is set to TRUE. If the workflow could not be found, an exception is thrown.
string | $workflowId | the id of the workflow to load |
boolean | $forceReload | force workflow reload |
$preload =array() |
$workflowNamePrefix ='sw' |