Skip to content

Commit

Permalink
Rename. Rafs midgardprojectgh-151
Browse files Browse the repository at this point in the history
  • Loading branch information
piotras committed Jan 28, 2013
1 parent 73b77f0 commit 05ad9ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Midgard/PHPCR/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,18 @@ public function addNodeAutoNamed($nameHint = null, $primaryNodeTypeName = null)

public function rename($newName)
{
if (isset($this->parent->children[$newName])) {
throw new \PHPCR\RepositoryException("'{$newName}' node already exist");
}

$this->oldName = $this->getName();
$midgardNode = $this->getMidgard2Node();
$midgardNode->name = $newName;

$this->parent->children[$newName] = $this;
unset($this->parent->children[$this->oldName]);

$this->is_modified = true;
}

public function getNodeNames()
Expand Down

0 comments on commit 05ad9ba

Please sign in to comment.