private function processNode(Node $node) { if (false === $node->hasProperty(Storage::JCR_UUID)) { return; } $jcrUuid = UUIDHelper::generateUUID(); $node->setProperty(Storage::JCR_UUID, $jcrUuid, 'String'); }
/** * Write the given node data. * * @return array Node data */ public function writeNode($workspace, $path, Node $node) { $internalUuid = $this->getOrCreateInternalUuid($path); $node->setProperty(Storage::INTERNAL_UUID, $internalUuid, 'String'); $jcrUuid = null; if ($node->hasProperty('jcr:mixinTypes')) { $mixinTypes = $node->getPropertyValue('jcr:mixinTypes'); if (in_array('mix:referenceable', $mixinTypes)) { if (false === $node->hasProperty('jcr:uuid')) { $jcrUuid = UUIDHelper::generateUUID(); $node->setProperty('jcr:uuid', $jcrUuid); } else { $jcrUuid = $node->getPropertyValue('jcr:uuid'); } } } $serialized = $this->serializer->serialize($node); $absPath = $this->helper->getNodePath($workspace, $path); $this->filesystem->write($absPath, $serialized); foreach ($this->serializer->getSerializedBinaries() as $binaryHash => $binaryData) { // TODO: use Helper to get path ..., $binaryPath = sprintf('%s/%s.bin', dirname($absPath), $binaryHash); $this->filesystem->write($binaryPath, $binaryData); } $this->index->indexUuid($internalUuid, $workspace, $path, true); if ($jcrUuid) { $this->index->indexUuid($jcrUuid, $workspace, $path, false); } foreach ($node->getProperties() as $propertyName => $property) { foreach ((array) $property['value'] as $propertyValue) { if ($property['type'] === 'Reference') { $this->index->indexReferrer($internalUuid, $propertyName, $propertyValue, false); } if ($property['type'] === 'WeakReference') { $this->index->indexReferrer($internalUuid, $propertyName, $propertyValue, true); } } } return $node; }