PHP Class ezcWorkflowNode, Workflow

All workflow nodes must extend this class.
Inheritance: implements ezcWorkflowVisitable
Show file Open project: zetacomponents/workflow Class Usage Examples

Protected Properties

Property Type Description
$activatedFrom ezcWorkflowNode[] The node(s) that activated this node.
$activationState integer The state of this node.
$configuration The configuration is a structured (hash) array with the various options of the implemented node. This functionality is implemented as an array to make it possible to have the storage engines unaware of the node classes.
$id integer Only available when the workflow this node belongs to has been loaded from or saved to the data storage.
$inNodes The incoming nodes of this node.
$internalCall boolean Flag that indicates whether an add*Node() or remove*Node() call is internal. This is necessary to avoid unlimited loops.
$maxInNodes integer Constraint: The maximum number of incoming nodes this node has to have to be valid. Set to false to disable this constraint.
$maxOutNodes integer Constraint: The maximum number of outgoing nodes this node has to have to be valid. Set to false to disable this constraint.
$minInNodes integer Constraint: The minimum number of incoming nodes this node has to have to be valid. Set to false to disable this constraint.
$minOutNodes integer Constraint: The minimum number of outgoing nodes this node has to have to be valid. Set to false to disable this constraint.
$numInNodes integer The number of incoming nodes.
$numOutNodes integer The number of outgoing nodes.
$outNodes The outgoing nodes of this node.
$state mixed The state of this node.
$threadId integer The id of the thread this node is executing in.

Public Methods

Method Description
__construct ( mixed $configuration = null ) Constructs a new node with the configuration $configuration.
__toString ( ) : string Returns a textual representation of this node.
accept ( ezcWorkflowVisitor $visitor ) Reimplementation of accept() calls accept on all out nodes.
activate ( ezcWorkflowExecution $execution, ezcWorkflowNode $activatedFrom = null, integer $threadId ) Activate this node in the execution environment $execution.
addInNode ( ezcWorkflowNode $node ) : ezcWorkflowNode Adds a node to the incoming nodes of this node.
addOutNode ( ezcWorkflowNode $node ) : ezcWorkflowNode Adds a node to the outgoing nodes of this node.
configurationFromXML ( DOMElement $element ) Generate node configuration from XML representation.
configurationToXML ( DOMElement $element ) Generate XML representation of this node's configuration.
execute ( ezcWorkflowExecution $execution ) : boolean Executes and performs the workflow duties of this node and returns true if the node completed execution.
getActivatedFrom ( ) : array Returns the node(s) that activated this node.
getConfiguration ( ) : mixed Returns the configuration of this node.
getId ( ) : integer Returns the Id of this node.
getInNodes ( ) : ezcWorkflowNode[] Returns the incoming nodes of this node.
getOutNodes ( ) : ezcWorkflowNode[] Returns the outgoing nodes of this node.
getState ( ) : mixed Returns the state of this node.
getThreadId ( ) : integer Returns the id of the thread this node is executing in.
initState ( ) Initializes the state of this node.
isExecutable ( ) : boolean Returns true if this node is ready for execution and false if it is not.
removeInNode ( ezcWorkflowNode $node ) : boolean Removes a node from the incoming nodes of this node.
removeOutNode ( ezcWorkflowNode $node ) : boolean Removes a node from the outgoing nodes of this node.
setActivatedFrom ( array $activatedFrom ) Sets the node(s) that activated this node.
setActivationState ( integer $activationState ) Sets the activation state for this node.
setId ( integer $id ) Sets the Id of this node.
setState ( mixed $state ) Sets the state of this node.
setThreadId ( integer $threadId ) Sets the id of the thread this node is executing in.
verify ( ) Checks this node's constraints.

Protected Methods

Method Description
activateNode ( ezcWorkflowExecution $execution, ezcWorkflowNode $node ) Convenience method for activating an (outgoing) node.

Method Details

__construct() public method

The configuration is a structured (hash) array. Implementations must pass their complete configuration on to this object. We have chosen to use structured arrays for the configuration since it simplifies the process of creating new node types and storing workflows.
public __construct ( mixed $configuration = null )
$configuration mixed

__toString() public method

Returns a textual representation of this node.
public __toString ( ) : string
return string

accept() public method

Reimplementation of accept() calls accept on all out nodes.
public accept ( ezcWorkflowVisitor $visitor )
$visitor ezcWorkflowVisitor

activate() public method

$activatedFrom is the node that activated this node and $threadId is threadId of the thread the node should be activated in. This method is called by other nodes and/or the execution environment depending on the workflow.
public activate ( ezcWorkflowExecution $execution, ezcWorkflowNode $activatedFrom = null, integer $threadId )
$execution ezcWorkflowExecution
$activatedFrom ezcWorkflowNode
$threadId integer

activateNode() protected method

Convenience method for activating an (outgoing) node.
protected activateNode ( ezcWorkflowExecution $execution, ezcWorkflowNode $node )
$execution ezcWorkflowExecution
$node ezcWorkflowNode

addInNode() public method

Automatically adds $node to the workflow and adds this node as an out node of $node.
public addInNode ( ezcWorkflowNode $node ) : ezcWorkflowNode
$node ezcWorkflowNode The node that is to be added as incoming node.
return ezcWorkflowNode

addOutNode() public method

Automatically adds $node to the workflow and adds this node as an in node of $node.
public addOutNode ( ezcWorkflowNode $node ) : ezcWorkflowNode
$node ezcWorkflowNode The node that is to be added as outgoing node.
return ezcWorkflowNode

configurationFromXML() public static method

Generate node configuration from XML representation.
public static configurationFromXML ( DOMElement $element )
$element DOMElement

configurationToXML() public method

Generate XML representation of this node's configuration.
public configurationToXML ( DOMElement $element )
$element DOMElement

execute() public method

Implementations of ezcWorkflowNode should reimplement this method. This method is called automatically by the workflow execution environment and should not be called directly. The default implementation resets the activation state of the node.
public execute ( ezcWorkflowExecution $execution ) : boolean
$execution ezcWorkflowExecution
return boolean true when the node finished execution, and false otherwise

getActivatedFrom() public method

Returns the node(s) that activated this node.
public getActivatedFrom ( ) : array
return array

getConfiguration() public method

Returns the configuration of this node.
public getConfiguration ( ) : mixed
return mixed

getId() public method

Returns the Id of this node.
public getId ( ) : integer
return integer

getInNodes() public method

Returns the incoming nodes of this node.
public getInNodes ( ) : ezcWorkflowNode[]
return ezcWorkflowNode[]

getOutNodes() public method

Returns the outgoing nodes of this node.
public getOutNodes ( ) : ezcWorkflowNode[]
return ezcWorkflowNode[]

getState() public method

Returns the state of this node.
public getState ( ) : mixed
return mixed

getThreadId() public method

Returns the id of the thread this node is executing in.
public getThreadId ( ) : integer
return integer

initState() public method

Initializes the state of this node.
public initState ( )

isExecutable() public method

Returns true if this node is ready for execution and false if it is not.
public isExecutable ( ) : boolean
return boolean

removeInNode() public method

Automatically removes $this as an out node of $node.
public removeInNode ( ezcWorkflowNode $node ) : boolean
$node ezcWorkflowNode The node that is to be removed as incoming node.
return boolean

removeOutNode() public method

Automatically removes $this as an in node of $node.
public removeOutNode ( ezcWorkflowNode $node ) : boolean
$node ezcWorkflowNode The node that is to be removed as outgoing node.
return boolean

setActivatedFrom() public method

Sets the node(s) that activated this node.
public setActivatedFrom ( array $activatedFrom )
$activatedFrom array

setActivationState() public method

One of ezcWorkflowNode::WAITING_FOR_ACTIVATION or ezcWorkflowNode::WAITING_FOR_EXECUTION.
public setActivationState ( integer $activationState )
$activationState integer

setId() public method

Sets the Id of this node.
public setId ( integer $id )
$id integer

setState() public method

Sets the state of this node.
public setState ( mixed $state )
$state mixed

setThreadId() public method

Sets the id of the thread this node is executing in.
public setThreadId ( integer $threadId )
$threadId integer

verify() public method

The constraints checked are the minimum in nodes maximum in nodes, minimum out nodes and maximum out nodes.
public verify ( )

Property Details

$activatedFrom protected property

The node(s) that activated this node.
protected ezcWorkflowNode[] $activatedFrom
return ezcWorkflowNode[]

$activationState protected property

The state of this node.
protected int $activationState
return integer

$configuration protected property

The configuration is a structured (hash) array with the various options of the implemented node. This functionality is implemented as an array to make it possible to have the storage engines unaware of the node classes.
protected $configuration

$id protected property

Only available when the workflow this node belongs to has been loaded from or saved to the data storage.
protected int $id
return integer

$inNodes protected property

The incoming nodes of this node.
protected $inNodes

$internalCall protected static property

Flag that indicates whether an add*Node() or remove*Node() call is internal. This is necessary to avoid unlimited loops.
protected static bool $internalCall
return boolean

$maxInNodes protected property

Constraint: The maximum number of incoming nodes this node has to have to be valid. Set to false to disable this constraint.
protected int $maxInNodes
return integer

$maxOutNodes protected property

Constraint: The maximum number of outgoing nodes this node has to have to be valid. Set to false to disable this constraint.
protected int $maxOutNodes
return integer

$minInNodes protected property

Constraint: The minimum number of incoming nodes this node has to have to be valid. Set to false to disable this constraint.
protected int $minInNodes
return integer

$minOutNodes protected property

Constraint: The minimum number of outgoing nodes this node has to have to be valid. Set to false to disable this constraint.
protected int $minOutNodes
return integer

$numInNodes protected property

The number of incoming nodes.
protected int $numInNodes
return integer

$numOutNodes protected property

The number of outgoing nodes.
protected int $numOutNodes
return integer

$outNodes protected property

The outgoing nodes of this node.
protected $outNodes

$state protected property

The state of this node.
protected mixed $state
return mixed

$threadId protected property

The id of the thread this node is executing in.
protected int $threadId
return integer