/** * Function: mergeChildrenImpl * * Clones the children of the source cell into the given target cell in * this model and adds an entry to the mapping that maps from the source * cell to the target cell with the same id or the clone of the source cell * that was inserted into this model. */ function mergeChildrenImpl($from, $to, $cloneAllEdges, $mapping) { $this->beginUpdate(); try { $childCount = $from->getChildCount(); for ($i = 0; $i < $childCount; $i++) { $cell = $from->getChildAt($i); $id = $cell->getId(); $target = isset($d) && (!$this->isEdge($cell) || !$cloneAllEdges) ? $this->getCell($id) : null; // Clones and adds the child if no cell exists for the id if (!isset($target)) { $clone = $cell->clone(); $clone->setId($id); // Sets the terminals from the original cell to the clone // because the lookup uses strings not cells in PHP $clone->setTerminal($cell->getTerminal(true), true); $clone->setTerminal($cell->getTerminal(false), false); // Do *NOT* use model.add as this will move the edge away // from the parent in updateEdgeParent if maintainEdgeParent // is enabled in the target model $target = $to->insert($clone); $this->cellAdded($target); } // Stores the mapping for later reconnecting edges $mapping[mxCellPath::create($cell)] = $target; // Recurses $this->mergeChildrenImpl($cell, $target, $cloneAllEdges, $mapping); } } catch (Exception $e) { $this->endUpdate(); throw $e; } $this->endUpdate(); }
/** * Function: getId * * Returns the ID of the specified object. This implementation * calls <reference> first and if that returns null handles * the object as an <mxCell> by returning their IDs using * <mxCell.getId>. If no ID exists for the given cell, then * an on-the-fly ID is generated using <mxCellPath.create>. * * Parameters: * * obj - Object to return the ID for. */ function getId($obj) { $id = null; if (isset($obj)) { $id = $this->reference($obj); if (!isset($id) && mxCodecRegistry::getName($obj) == "mxCell") { $id = $obj->getId(); if (!isset($id)) { // Uses an on-the-fly Id $id = mxCellPath::create($obj); if (strlen($id) == 0) { $id = "root"; } } } } return $id; }