/** * Creates every node on the path to the given node. Also uses the same UUIDs for these nodes. * * @param NodeInterface $node */ private function createNodesWithUuid(NodeInterface $node) { $path = $node->getPath(); if ($this->liveSession->itemExists($path)) { return; } $currentDefaultNode = $node->getSession()->getRootNode(); $currentLiveNode = $this->liveSession->getRootNode(); $pathSegments = explode('/', ltrim($path, '/')); foreach ($pathSegments as $pathSegment) { $currentDefaultNode = $currentDefaultNode->getNode($pathSegment); if ($currentLiveNode->hasNode($pathSegment)) { $currentLiveNode = $currentLiveNode->getNode($pathSegment); continue; } $currentLiveNode = $currentLiveNode->addNode($pathSegment); $currentLiveNode->setMixins(['mix:referenceable']); $currentLiveNode->setProperty('jcr:uuid', $currentDefaultNode->getIdentifier()); } }