/** * * @param string * The path of the new {@link Node} to be created. * @param string|null * The name of the primary {@link NodeType} of the new {@link Node}. * (Optional) * @return jr_cr_node * A {@link Node} object * @throws {@link ItemExistsException} * If an item at the specified path already exists, same-name siblings * are not allowed and this implementation performs this validation * immediately instead of waiting until {@link save()}. * @throws {@link PathNotFoundException} * If the specified path implies intermediary {@link Node}s that do not * exist or the last element of <i>$relPath</i> has an index, and * this implementation performs this validation immediately instead of * waiting until {@link save()}. * @throws {@link NoSuchNodeTypeException} * If the specified node type is not recognized and this implementation * performs this validation immediately instead of waiting until * {@link save()}. * @throws {@link ConstraintViolationException} * If a node type or implementation-specific constraint is violated or * if an attempt is made to add a node as the child of a property and * this implementation performs this validation immediately instead of * waiting until {@link save()}. * @throws {@link VersionException} * If the node to which the new child is being added is versionable and * checked-in or is non-versionable but its nearest versionable ancestor * is checked-in and this implementation performs this validation * immediately instead of waiting until {@link save()}. * @throws {@link LockException} * If a lock prevents the addition of the node and this implementation * performs this validation immediately instead of waiting until * {@link save()}. * @throws {@link RepositoryException} * If the last element of <i>$relPath</i> has an index or if * another error occurs. * @see PHPCR_Node::addNode() */ public function addNode($relPath, $primaryNodeTypeName = null, $identifier = null) { try { if ($node = $this->getNode($relPath)) { // FIXME, should throw an exception return $node; } } catch (Exception $e) { //ignore and continue, just wanted to make sure there is not already a node here } if (substr($relPath, 0, 1) == '/') { $node = $this->session->getRootNode(); $relPath = substr($relPath, 1); } else { if (!$relPath || $relPath == '') { $relPath = "."; $node = $this; } else { $node = $this; } } if (!$primaryNodeTypeName) { $jrnode = $node->JRnode->addNode($relPath); } else { $jrnode = $node->JRnode->addNode($relPath, $primaryNodeTypeName); } $node = new jr_cr_node($this->session, $jrnode); $node->setNew(true); $node->setModified(true); return $node; }