浏览代码

Model factory: introduced a new variation of attribute _delta: delete_if_exists. Use this flag to delete a branch from the data model being hacked, without caring if it is already deleted (or non existing). This eases the burden of coping with different installation combinations.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4306 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 9 年之前
父节点
当前提交
8f179b8e11
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. 11 1
      setup/modelfactory.class.inc.php

+ 11 - 1
setup/modelfactory.class.inc.php

@@ -490,7 +490,17 @@ class ModelFactory
 			$oTargetParentNode->RedefineChildNode($oTargetNode, $sSearchId);
 			break;
 
-		case 'delete':
+		case 'delete_if_exists':
+			$oTargetNode = $oTargetParentNode->_FindChildNode($oSourceNode);
+			if (($oTargetNode !== null) && ($oTargetNode->getAttribute('_alteration') !== 'removed'))
+			{
+				// Delete the node if it actually exists and is not already marked as deleted
+				$oTargetNode->Delete();
+			}
+			// otherwise fail silently
+			break;
+			
+		case 'delete':			
 			$oTargetNode = $oTargetParentNode->_FindChildNode($oSourceNode);
 			if ($oTargetNode == null)
 			{