* $set = new ezcWorkflowNodeVariableSet ( array ( 'variable name' = > $value ) ); * * * Incoming nodes: 1 * Outgoing nodes: 1 * * @package Workflow * @version 1.1rc1 */ class ezcWorkflowNodeVariableSet extends ezcWorkflowNode { /** * Constructs a new variable set node with the configuration $configuration. * * The configuration is an array of keys and values of the format: * array( 'workflow variable name' => value ) * * @param mixed $configuration * @throws ezcBaseValueException */ public function __construct( $configuration = '' ) { if ( !is_array( $configuration ) ) { throw new ezcBaseValueException( 'configuration', $configuration, 'array' ); } parent::__construct( $configuration ); } /** * Executes this by setting all the variables specified by the * configuration. * * @param ezcWorkflowExecution $execution * @ignore */ public function execute( ezcWorkflowExecution $execution ) { foreach ( $this->configuration as $variable => $value ) { $execution->setVariable( $variable, $value ); } $this->activateNode( $execution, $this->outNodes[0] ); return parent::execute( $execution ); } /** * Generate node configuration from XML representation. * * @param DOMElement $element */ public static function configurationFromXML( DOMElement $element ) { $configuration = array(); foreach ( $element->getElementsByTagName( 'variable' ) as $variable ) { $configuration[$variable->getAttribute( 'name' )] = ezcWorkflowDefinitionStorageXml::xmlToVariable( $variable->childNodes->item( 1 ) ); } return $configuration; } /** * Generate XML representation of this node's configuration. * * @param DOMElement $element */ public function configurationToXML( DOMElement $element ) { foreach ( $this->configuration as $variable => $value ) { $variableXml = $element->appendChild( $element->ownerDocument->createElement( 'variable' ) ); $variableXml->setAttribute( 'name', $variable ); $variableXml->appendChild( ezcWorkflowDefinitionStorageXml::variableToXml( $value, $element->ownerDocument ) ); } } /** * Returns a textual representation of this node. * * @return string * @ignore */ public function __toString() { $buffer = array(); foreach ( $this->configuration as $variable => $value ) { $buffer[] = $variable . ' = ' . ezcWorkflowUtil::variableToString( $value ); } return implode( ', ', $buffer ); } } ?>