Doctrine\ODM\PHPCR\UnitOfWork::getChildNodename PHP Method

getChildNodename() private method

Determine the nodename of a child in a children list.
private getChildNodename ( string $parentId, string $nodename, object $child, object $parent ) : mixed | string
$parentId string Id of the parent document
$nodename string Name to use if we can't determine the node name otherwise.
$child object The child document
$parent object The parent document
return mixed | string
    private function getChildNodename($parentId, $nodename, $child, $parent)
    {
        $childClass = $this->dm->getClassMetadata(get_class($child));
        if ($childClass->nodename && $childClass->reflFields[$childClass->nodename]->getValue($child)) {
            $nodename = $childClass->reflFields[$childClass->nodename]->getValue($child);
            if ($exception = $childClass->isValidNodename($nodename)) {
                throw IdException::illegalName($child, $childClass->nodename, $nodename);
            }
        } else {
            $childId = '';
            if ($childClass->identifier) {
                $childId = $childClass->getIdentifierValue($child);
            }
            if (!$childId) {
                $generator = $this->getIdGenerator($childClass->idGenerator);
                $childId = $generator->generate($child, $childClass, $this->dm, $parent);
            }
            if ('' !== $childId) {
                if ($childId !== $parentId . '/' . PathHelper::getNodeName($childId)) {
                    throw PHPCRException::cannotMoveByAssignment(self::objToStr($child, $this->dm));
                }
                $nodename = PathHelper::getNodeName($childId);
            }
        }
        return $nodename;
    }
UnitOfWork