*
String: The name of the workflow variable to operate on.
*
* Array:
*
* - name: The name of the workflow variable to operate on.
* - operand: Name of workflow variable or a numerical value.
* Not used by implementations without an operand.
*
*
*
*
* @param mixed $configuration
* @throws ezcWorkflowDefinitionStorageException
*/
public function __construct( $configuration )
{
parent::__construct( $configuration );
}
/**
* Executes this node and returns true.
*
* Expects the configuration parameters 'name' the name of the workflow
* variable to work on and the parameter 'value' the value to operate with
* or the name of the workflow variable containing the value.
*
* @param ezcWorkflowExecution $execution
* @return boolean
* @ignore
*/
public function execute( ezcWorkflowExecution $execution )
{
if ( is_array( $this->configuration ) )
{
$variableName = $this->configuration['name'];
}
else
{
$variableName = $this->configuration;
}
$this->variable = $execution->getVariable( $variableName );
if ( !is_numeric( $this->variable ) )
{
throw new ezcWorkflowExecutionException(
sprintf(
'Variable "%s" is not a number.',
$variableName
)
);
}
if ( is_numeric( $this->configuration['operand'] ) )
{
$this->operand = $this->configuration['operand'];
}
else if ( is_string( $this->configuration['operand'] ) )
{
try
{
$operand = $execution->getVariable( $this->configuration['operand'] );
if ( is_numeric( $operand ) )
{
$this->operand = $operand;
}
}
catch ( ezcWorkflowExecutionException $e )
{
}
}
if ( $this->operand === null )
{
throw new ezcWorkflowExecutionException( 'Illegal operand.' );
}
$this->doExecute();
$execution->setVariable( $variableName, $this->variable );
$this->activateNode( $execution, $this->outNodes[0] );
return parent::execute( $execution );
}
/**
* Implementors should perform the variable computation in this method.
*
* doExecute() is called automatically by execute().
*/
abstract protected function doExecute();
}
?>