Author: Sebastian Bergmann
Date: 2007-01-27 11:37:31 +0100 (Sat, 27 Jan 2007)
New Revision: 4589

Log:
- Simplify.
Modified:
   experimental/Workflow/src/interfaces/node.php

Modified: experimental/Workflow/src/interfaces/node.php
===================================================================
--- experimental/Workflow/src/interfaces/node.php       2007-01-27 10:09:55 UTC 
(rev 4588)
+++ experimental/Workflow/src/interfaces/node.php       2007-01-27 10:37:31 UTC 
(rev 4589)
@@ -139,6 +139,14 @@
     protected $threadId = null;
 
     /**
+     * Flag that indicates whether an add*Node() or remove*Node()
+     * call is internal.
+     *
+     * @var boolean
+     */
+    protected static $internalCall = false;
+
+    /**
      * Constructor.
      *
      * @param mixed   $configuration
@@ -163,14 +171,12 @@
 
     /**
      * Adds a node to the incoming nodes of this node.
-     * Optionally adds this node as an outgoing node to the other node.
      *
      * @param ezcWorkflowNode $node The node that is to be added as incoming 
node.
-     * @param boolean $addAsOutNode Whether this node should be added as an 
outgoing node. This parameter is for internal use only.
      * @throws ezcWorkflowInvalidDefinitionException if the operation violates 
the constraints of the nodes involved.
      * @return boolean true when the node was added, false otherwise.
      */
-    public function addInNode( ezcWorkflowNode $node, $addAsOutNode = true )
+    public function addInNode( ezcWorkflowNode $node )
     {
         // Check whether the node is already an incoming node of this node.
         if ( ezcWorkflowUtil::findObject( $this->inNodes, $node ) !== false )
@@ -191,10 +197,15 @@
         $this->addNodeToWorkflow( $node );
 
         // Add this node as an outgoing node to the other node.
-        if ( $addAsOutNode )
+        if ( !self::$internalCall )
         {
-            $node->addOutNode ( $this, false );
+            self::$internalCall = true;
+            $node->addOutNode( $this );
         }
+        else
+        {
+            self::$internalCall = false;
+        }
 
         // Add the other node as an incoming node to this node.
         $this->inNodes[] = $node;
@@ -205,14 +216,12 @@
 
     /**
      * Removes a node from the incoming nodes of this node.
-     * Optionally removes this node as an outgoing node from the other node.
      *
      * @param ezcWorkflowNode $node The node that is to be removed as incoming 
node.
-     * @param boolean $addAsOutNode Whether this node should be removed as an 
outgoing node. This parameter is for internal use only.
      * @throws ezcWorkflowInvalidDefinitionException if the operation violates 
the constraints of the nodes involved.
      * @return boolean true when the node was removed, false otherwise.
      */
-    public function removeInNode( ezcWorkflowNode $node, $removeAsOutNode = 
true )
+    public function removeInNode( ezcWorkflowNode $node )
     {
         $index = ezcWorkflowUtil::findObject( $this->inNodes, $node );
 
@@ -228,10 +237,16 @@
             );
         }
 
-        if ( $removeAsOutNode )
+        // Remove this node as an outgoing node from the other node.
+        if ( !self::$internalCall )
         {
-            $node->removeOutNode ( $this, false );
+            self::$internalCall = true;
+            $node->removeOutNode( $this );
         }
+        else
+        {
+            self::$internalCall = false;
+        }
 
         unset( $this->inNodes[$index] );
         $this->numInNodes--;
@@ -241,14 +256,12 @@
 
     /**
      * Adds a node to the outgoing nodes of this node.
-     * Optionally adds this node as an incoming node to the other node.
      *
      * @param ezcWorkflowNode $node The node that is to be added as outgoing 
node.
-     * @param boolean $addAsInNode Whether this node should be added as an 
incoming node. This parameter is for internal use only.
      * @throws ezcWorkflowInvalidDefinitionException if the operation violates 
the constraints of the nodes involved.
      * @return boolean true when the node was added, false otherwise.
      */
-    public function addOutNode( ezcWorkflowNode $node, $addAsInNode = true )
+    public function addOutNode( ezcWorkflowNode $node )
     {
         // Check whether the other node is already an outgoing node of this 
node.
         if ( ezcWorkflowUtil::findObject( $this->outNodes, $node ) !== false )
@@ -269,10 +282,15 @@
         $this->addNodeToWorkflow( $node );
 
         // Add this node as an incoming node to the other node.
-        if ( $addAsInNode )
+        if ( !self::$internalCall )
         {
-            $node->addInNode ( $this, false );
+            self::$internalCall = true;
+            $node->addInNode( $this );
         }
+        else
+        {
+            self::$internalCall = false;
+        }
 
         // Add the other node as an outgoing node to this node.
         $this->outNodes[] = $node;
@@ -283,14 +301,12 @@
 
     /**
      * Removes a node from the outgoing nodes of this node.
-     * Optionally removes this node as an incoming node from the other node.
      *
      * @param ezcWorkflowNode $node The node that is to be removed as outgoing 
node.
-     * @param boolean $addAsOutNode Whether this node should be removed as an 
incoming node. This parameter is for internal use only.
      * @throws ezcWorkflowInvalidDefinitionException if the operation violates 
the constraints of the nodes involved.
      * @return boolean true when the node was removed, false otherwise.
      */
-    public function removeOutNode( ezcWorkflowNode $node, $removeAsInNode = 
true )
+    public function removeOutNode( ezcWorkflowNode $node )
     {
         $index = ezcWorkflowUtil::findObject( $this->outNodes, $node );
 
@@ -306,10 +322,16 @@
             );
         }
 
-        if ( $removeAsInNode )
+        // Remove this node as an incoming node from the other node.
+        if ( !self::$internalCall )
         {
-            $node->removeInNode ( $this, false );
+            self::$internalCall = true;
+            $node->removeInNode( $this );
         }
+        else
+        {
+            self::$internalCall = false;
+        }
 
         unset( $this->outNodes[$index] );
         $this->numOutNodes--;

-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to