A simple workflow behavior for Yii ActiveRecord
 All Data Structures Files Functions Variables Pages
SWWorkflowSource Class Reference
Inheritance diagram for SWWorkflowSource:
SWPhpWorkflowSource

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'
 

Detailed Description

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.

Member Function Documentation

addWorkflow (   $definition,
  $id 
)
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.

Parameters
array$definitionworkflow definition
string$idunique 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.

Returns
SWNode the node object
getAllNodes (   $workflowId)
abstract

Fetch all nodes belonging to the workflow whose Id is passed as argument.

Parameters
string$workflowIdid of the workflow that owns all nodes returned
Returns
array all nodes belonging to workflow $workflowId
getInitialNode (   $workflowId)
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.

Returns
SWnode initial node for $workflowId
getNextNodes (   $sourceNode,
  $workflowId = null 
)
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.

Returns
array SWNode array
getNodeDefinition (   $node,
  $defaultWorkflowId = null 
)
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.

Parameters
mixednode String or SWNode object to look for
Returns
SWNode the node as it is defined in a workflow, or NULL if not found
isNextNode (   $sourceNode,
  $targetNode,
  $workflowId = null 
)
abstract

Checks if there is a transition between the two nodes passed as argument.

Parameters
mixed$sourceNodecan be provided as a SWNode object, or as a string that can contain a workflowId or not.
mixed$targetNodetarget node to test
Returns
boolean true if $nextStatus can be reached from $startStatus
loadWorkflow (   $workflowId,
  $forceReload = false 
)
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.

Parameters
string$workflowIdthe id of the workflow to load
boolean$forceReloadforce workflow reload

Field Documentation

$preload =array()
$workflowNamePrefix ='sw'

The documentation for this class was generated from the following file: