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

executeMoves() private method

Executes all document moves
private executeMoves ( array $documents )
$documents array array of all to be moved documents
    private function executeMoves($documents)
    {
        foreach ($documents as $oid => $value) {
            if (!$this->contains($oid)) {
                continue;
            }
            list($document, $targetPath) = $value;
            $sourcePath = $this->getDocumentId($document);
            if ($sourcePath === $targetPath) {
                continue;
            }
            $class = $this->dm->getClassMetadata(get_class($document));
            if ($invoke = $this->eventListenersInvoker->getSubscribedSystems($class, Event::preMove)) {
                $this->eventListenersInvoker->invoke($class, Event::preMove, $document, new MoveEventArgs($document, $this->dm, $sourcePath, $targetPath), $invoke);
            }
            $parentNode = $this->session->getNode(PathHelper::getParentPath($targetPath));
            $this->validateChildClass($parentNode, $class);
            $this->session->move($sourcePath, $targetPath);
            // update fields nodename, parentMapping and depth if they exist in this type
            $node = $this->session->getNode($targetPath);
            // get node from session, document class might not map it
            if ($class->nodename) {
                $class->setFieldValue($document, $class->nodename, $node->getName());
            }
            if ($class->parentMapping) {
                $class->setFieldValue($document, $class->parentMapping, $this->getOrCreateProxyFromNode($node->getParent(), $this->getCurrentLocale($document, $class)));
            }
            if ($class->depthMapping) {
                $class->setFieldValue($document, $class->depthMapping, $node->getDepth());
            }
            // update all cached children of the document to reflect the move (path id changes)
            foreach ($this->documentIds as $childOid => $id) {
                if (0 !== strpos($id, $sourcePath)) {
                    continue;
                }
                $newId = $targetPath . substr($id, strlen($sourcePath));
                $this->documentIds[$childOid] = $newId;
                $child = $this->getDocumentById($id);
                if (!$child) {
                    continue;
                }
                unset($this->identityMap[$id]);
                $this->identityMap[$newId] = $child;
                $childClass = $this->dm->getClassMetadata(get_class($child));
                if ($childClass->identifier) {
                    $childClass->setIdentifierValue($child, $newId);
                    if (!$child instanceof Proxy || $child->__isInitialized()) {
                        $this->originalData[$oid][$childClass->identifier] = $newId;
                    }
                }
            }
            if ($invoke = $this->eventListenersInvoker->getSubscribedSystems($class, Event::postMove)) {
                $this->eventListenersInvoker->invoke($class, Event::postMove, $document, new MoveEventArgs($document, $this->dm, $sourcePath, $targetPath), $invoke);
            }
        }
    }
UnitOfWork