public function onPostDeserialize(ObjectEvent $event) { $document = $event->getObject(); // only register documents if (!$this->metadataFactory->hasMetadataForClass(get_class($document))) { return; } if (!$document->getUuid()) { return; } try { $node = $this->nodeManager->find($document->getUuid()); } catch (DocumentNotFoundException $e) { return; } if ($this->registry->hasNode($node, $document->getLocale())) { $registeredDocument = $this->registry->getDocumentForNode($node, $document->getLocale()); $this->registry->deregisterDocument($registeredDocument); } // TODO use the original locale somehow if (!$this->registry->hasDocument($document)) { $this->registry->registerDocument($document, $node, $document->getLocale()); } }