Neos\ContentRepository\Domain\Model\Node::setName PHP Method

setName() public method

Set the name of the node to $newName, keeping its position as it is.
public setName ( string $newName ) : void
$newName string
return void
    public function setName($newName)
    {
        if ($this->getName() === $newName) {
            return;
        }
        if (!is_string($newName) || preg_match(NodeInterface::MATCH_PATTERN_NAME, $newName) !== 1) {
            throw new \InvalidArgumentException('Invalid node name "' . $newName . '" (a node name must only contain lowercase characters, numbers and the "-" sign).', 1364290748);
        }
        if ($this->getPath() === '/') {
            throw new NodeException('The root node cannot be renamed.', 1346778388);
        }
        $this->setPath(NodePaths::addNodePathSegment($this->getParentPath(), $newName));
        $this->nodeDataRepository->persistEntities();
        $this->context->getFirstLevelNodeCache()->flush();
        $this->emitNodeUpdated($this);
    }
Node