public static function xmlToCondition(DOMElement $element)
{
$class = 'ezcWorkflowCondition' . $element->getAttribute('type');
switch ($class) {
case 'ezcWorkflowConditionVariable':
return new $class($element->getAttribute('name'), self::xmlToCondition(ezcWorkflowUtil::getChildNode($element)));
break;
case 'ezcWorkflowConditionVariables':
return new $class($element->getAttribute('a'), $element->getAttribute('b'), self::xmlToCondition(ezcWorkflowUtil::getChildNode($element)));
break;
case 'ezcWorkflowConditionAnd':
case 'ezcWorkflowConditionOr':
case 'ezcWorkflowConditionXor':
$conditions = array();
foreach (ezcWorkflowUtil::getChildNodes($element) as $childNode) {
if ($childNode->tagName == 'condition') {
$conditions[] = self::xmlToCondition($childNode);
}
}
return new $class($conditions);
break;
case 'ezcWorkflowConditionNot':
return new $class(self::xmlToCondition(ezcWorkflowUtil::getChildNode($element)));
break;
case 'ezcWorkflowConditionIsEqual':
case 'ezcWorkflowConditionIsEqualOrGreaterThan':
case 'ezcWorkflowConditionIsEqualOrLessThan':
case 'ezcWorkflowConditionIsGreaterThan':
case 'ezcWorkflowConditionIsLessThan':
case 'ezcWorkflowConditionIsNotEqual':
return new $class($element->getAttribute('value'));
break;
case 'ezcWorkflowConditionInArray':
return new $class(self::xmlToVariable(ezcWorkflowUtil::getChildNode($element)));
break;
default:
return new $class();
break;
}
}