示例#1
0
 /**
  * Set parent for node (update parent children also). Should be called only once in lifetime of node!
  * @param ARouteNode $parent
  * @throws RouterException
  */
 protected function setParent(ARouteNode $parent)
 {
     // only one leaf per node should be allowed. Parent can not be leaf
     if ($parent->isLeaf()) {
         throw new RouterException("Parent can not be leaf");
     } else {
         if ($this->isLeaf() && $parent->hasLeaf()) {
             $message = "Only one leaf per node is allowed";
             throw new RouterException($message);
         }
     }
     $parent->children[] = $this;
 }