private function doSaveTranslation($document, NodeInterface $node, $metadata)
{
if (!$this->isDocumentTranslatable($metadata)) {
return;
}
$oid = spl_object_hash($document);
if (!empty($this->documentTranslations[$oid])) {
$strategy = $this->dm->getTranslationStrategy($metadata->translator);
foreach ($this->documentTranslations[$oid] as $locale => $data) {
if ($data) {
foreach ($data as $fieldName => $fieldValue) {
$this->originalTranslatedData[$oid][$locale][$fieldName] = $fieldValue;
}
$strategy->saveTranslation($data, $node, $metadata, $locale);
} else {
$strategy->removeTranslation($document, $node, $metadata, $locale);
$class = $this->dm->getClassMetadata(get_class($document));
if ($invoke = $this->eventListenersInvoker->getSubscribedSystems($class, Event::postRemoveTranslation)) {
$this->eventListenersInvoker->invoke($class, Event::postRemoveTranslation, $document, new LifecycleEventArgs($document, $this->dm), $invoke);
}
}
}
}
}