Doctrine\ODM\PHPCR\UnitOfWork::purgeChildren PHP 메소드

purgeChildren() 개인적인 메소드

recurse over all known child documents to remove them form this unit of work as their parent gets removed from phpcr. If you do not, flush will try to create orphaned nodes if these documents are modified which leads to a PHPCR exception
private purgeChildren ( object $document )
$document object
    private function purgeChildren($document)
    {
        if ($document instanceof Proxy && !$document->__isInitialized()) {
            return;
        }
        $class = $this->dm->getClassMetadata(get_class($document));
        foreach ($class->childMappings as $fieldName) {
            $child = $class->reflFields[$fieldName]->getValue($document);
            if ($child !== null) {
                $this->purgeChildren($child);
                $this->unregisterDocument($child);
            }
        }
    }
UnitOfWork