Path

ez components / documentation / api reference / 2008.2.3 / workflow


eZ Components 2008.2.3

Workflow: ezcWorkflowExecution

[ Tutorial ] [ Theoretical background ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcWorkflowExecution

Abstract base class for workflow execution engines. [source]
ezcWorkflowExecution provides all functionality necessary to execute a workflow. However, it does not provide functionality to make the execution of a workflow persistent and hence usuable over more than one PHP run.
Implementations must implement the do* methods and provide the means to store the execution data to a persistent medium.

Descendents

Child Class Description
ezcWorkflowExecutionNonInteractive Workflow execution engine for non-interactive workflows.
ezcWorkflowDatabaseExecution Workflow executer that suspends and resumes workflow execution states to and from a database.

Properties

ezcWorkflowDefinitonStorage read/write  $definitionStorage
The definition handler used to fetch subworkflows if needed.
ezcWorkflow read/write  $workflow
The workflow being executed.

Member Variables

protected ezcWorkflowNode[] $activatedNodes = array()
Nodes of the workflow being executed that are activated.
protected bool $cancelled
protected bool $ended
protected integer $id
Execution ID.
protected integer $nextThreadId = 0
Sequence for thread ids.
protected integer $numActivatedEndNodes = 0
Number of activated end nodes.
protected integer $numActivatedNodes = 0
Number of activated nodes.
protected array $plugins = array()
protected array(string=>mixed) $properties = array(
'definitionStorage' => null,
'workflow' => null
)

Container to hold the properties
protected bool $resumed
protected bool $suspended
protected array $threads = array()
Nodes of the workflow that started a new thread of execution.
protected array $variables = array()
protected array $waitingFor = array()

Method Summary

public bool addListener( $listener )
Adds a listener to this execution.
public bool addPlugin( $plugin )
Adds a plugin to this execution.
public void cancel( [$node = null] )
Cancels workflow execution with the node $endNode.
protected abstract void doEnd( )
Called by end() when workflow execution is ended.
protected abstract ezcWorkflowExecution doGetSubExecution( [$id = null] )
Returns a new execution object for a sub workflow.
protected abstract void doResume( )
Called by resume() when workflow execution is resumed.
protected abstract void doStart( $parentId )
Called by start() when workflow execution is initiated.
protected abstract void doSuspend( )
Called by suspend() when workflow execution is suspended.
public bool hasEnded( )
Returns true when the workflow execution has ended.
public bool isCancelled( )
Returns true when the workflow execution has been cancelled.
public bool isSuspended( )
Returns true when the workflow execution has been suspended.
protected void loadFromVariableHandlers( )
Loads data from variable handlers and merge it with the current execution data.
public bool removeListener( $listener )
Removes a listener from this execution.
public bool removePlugin( $plugin )
Removes a plugin from this execution.
public void resume( [$inputData = array()] )
Resumes workflow execution of a suspended workflow.
protected void saveToVariableHandlers( )
Saves data to execution data handlers.
public mixed start( [$parentId = 0] )
Starts the execution of the workflow and returns the execution id.

Methods

addListener

bool addListener( ezcWorkflowExecutionListener $listener )
Adds a listener to this execution.

Parameters

Name Type Description
$listener ezcWorkflowExecutionListener  

addPlugin

bool addPlugin( ezcWorkflowExecutionPlugin $plugin )
Adds a plugin to this execution.

Parameters

Name Type Description
$plugin ezcWorkflowExecutionPlugin  

cancel

void cancel( [ezcWorkflowNode $node = null] )
Cancels workflow execution with the node $endNode.

Parameters

Name Type Description
$node ezcWorkflowNode  

doEnd

void doEnd( )
Called by end() when workflow execution is ended.
Reimplementations can use this method to remove execution data from the persistent medium.

Redefined in descendants as

Method Description
ezcWorkflowExecutionNonInteractive::doEnd() End workflow execution.
ezcWorkflowDatabaseExecution::doEnd() End workflow execution.

doGetSubExecution

ezcWorkflowExecution doGetSubExecution( [int $id = null] )
Returns a new execution object for a sub workflow.
Called by getSubExecution to get a new execution environment for the new execution thread.
Reimplementations must return a new execution environment similar to themselves.

Parameters

Name Type Description
$id int  

Redefined in descendants as

Method Description
ezcWorkflowExecutionNonInteractive::doGetSubExecution() Returns a new execution object for a sub workflow.
ezcWorkflowDatabaseExecution::doGetSubExecution() Returns a new execution object for a sub workflow.

doResume

void doResume( )
Called by resume() when workflow execution is resumed.
Reimplementations can use this method to fetch execution data if necessary..

Redefined in descendants as

Method Description
ezcWorkflowExecutionNonInteractive::doResume() Resume workflow execution.
ezcWorkflowDatabaseExecution::doResume() Resume workflow execution.

doStart

void doStart( integer $parentId )
Called by start() when workflow execution is initiated.
Reimplementations can use this method to store workflow information to a persistent medium when execution is started.

Parameters

Name Type Description
$parentId integer  

Redefined in descendants as

Method Description
ezcWorkflowExecutionNonInteractive::doStart() Start workflow execution.
ezcWorkflowDatabaseExecution::doStart() Start workflow execution.

doSuspend

void doSuspend( )
Called by suspend() when workflow execution is suspended.
Reimplementations can use this method to variable and node information to a persistent medium.

Redefined in descendants as

Method Description
ezcWorkflowExecutionNonInteractive::doSuspend() Suspend workflow execution.
ezcWorkflowDatabaseExecution::doSuspend() Suspend workflow execution.

hasEnded

bool hasEnded( )
Returns true when the workflow execution has ended.

isCancelled

bool isCancelled( )
Returns true when the workflow execution has been cancelled.

isSuspended

bool isSuspended( )
Returns true when the workflow execution has been suspended.

loadFromVariableHandlers

void loadFromVariableHandlers( )
Loads data from variable handlers and merge it with the current execution data.

removeListener

bool removeListener( ezcWorkflowExecutionListener $listener )
Removes a listener from this execution.

Parameters

Name Type Description
$listener ezcWorkflowExecutionListener  

removePlugin

bool removePlugin( ezcWorkflowExecutionPlugin $plugin )
Removes a plugin from this execution.

Parameters

Name Type Description
$plugin ezcWorkflowExecutionPlugin  

resume

void resume( [ $inputData = array()] )
Resumes workflow execution of a suspended workflow.
$executionId is the id of the execution to resume. $inputData is an associative array of the format array( 'variable name' => value ) that should contain new workflow variable data required to resume execution.
Calls do doResume() before the variables are loaded using the variable handlers.

Parameters

Name Type Description
$inputData array The new input data.

Throws

ClassDescription
ezcWorkflowInvalidInputException if the input given does not match the expected data.
ezcWorkflowExecutionException if there is no prior ID for this execution.

saveToVariableHandlers

void saveToVariableHandlers( )
Saves data to execution data handlers.

start

mixed start( [int $parentId = 0] )
Starts the execution of the workflow and returns the execution id.
$parentId is used to specify the execution id of the parent workflow when executing subworkflows. It should not be used when manually starting workflows.
Calls doStart() right before the first node is activated.

Parameters

Name Type Description
$parentId int  

Throws

ClassDescription
ezcWorkflowExecutionException If no workflow has been set up for execution.

Last updated: Mon, 11 May 2009