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

Public Member Functions

 __construct ($node, $defaultWorkflowId=null)
 
 parseNodeId ($status, $workflowId)
 
 __get ($name)
 
 getWorkflowId ()
 
 getId ()
 
 getLabel ()
 
 getNext ()
 
 getConstraint ()
 
 getMetadata ()
 
 getNextNodeIds ()
 
 getTransitionTask ($endNode)
 
 __toString ()
 
 toString ()
 
 equals ($status)
 

Detailed Description

This class implements a graph node for the simpleWorkflow extension.

Constructor & Destructor Documentation

__construct (   $node,
  $defaultWorkflowId = null 
)

Creates a workflow node instance. If no workflowId is specified in the nodeId, then the $defaultWorkflowId is used.
Note that both workflow and node id must begin with a alphabetic character followed by aplha-numeric characters : all other characters are not accepted and cause an exception to be thrown (see SWNode::parseNodeId())

Parameters
mixed$nodeIf a string is passed as argument, it can be both in format workflowId/NodeId or simply 'nodeId'. In this last case, argument $defaultWorkflowIs must be provided, otherwise it is ignored.
The $node argument may also be provided as an associative array, with the following structure :
    {
        'id'         => string,         // mandatory
        'label'      => string ,        // optional
        'constraint' => string,         // optional
        'transition' => array,          // optional
        'metadata'   => array,          // optional
    }
Again, the 'id' value may contain a workflow id (e.g 'workflowId/nodeId') but if it's not the case then the second argument $defaultWorkflowId must be provided.
stringdefaultWorkflowId workflow Id that is used each time a workflow is needed to complete a status name.

Member Function Documentation

__get (   $name)

Overrides the default magic method defined at the CComponent level in order to return a metadata value if parent method fails.

See Also
CComponent::__get()
__toString ( )
equals (   $status)

SWnode comparator method. Note that only the node and the workflow id members are compared.

Parameters
mixedSWNode object or string. If a string is provided it is used to create a new SWNode object.
getConstraint ( )
getId ( )
getLabel ( )
getMetadata ( )
getNext ( )
getNextNodeIds ( )
getTransitionTask (   $endNode)
Returns
String the task for this transition or NULL if no task is defined
Parameters
mixed$endNodeSWNode instance or string that will be converted to SWNode instance (e.g 'workflowId/nodeId')
Exceptions
SWException
getWorkflowId ( )
parseNodeId (   $status,
  $workflowId 
)

Parse a status name and return it as an array. The string passed as argument may be a complete status name (e.g workflowId/nodeId) and if no workflowId is specified, then an exception is thrown. Both workflow and node ids must match following pattern:

     /^[[:alpha:]][[:alnum:]_]*$/
 

For instance :

  • ready : matches
  • to_process : matches
  • priority_1 : matches
  • 2_level : does not match
  • to-production : does not match
  • enable/disable : does not match
Parameters
stringstatus status name (wfId/nodeId or nodeId)
Returns
array the complete status (e.g array ( [workflow] => 'a' [node] => 'b' ))
toString ( )

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