public function removeTranslation($document, $locale)
{
$class = $this->dm->getClassMetadata(get_class($document));
if ($invoke = $this->eventListenersInvoker->getSubscribedSystems($class, Event::preRemoveTranslation)) {
$this->eventListenersInvoker->invoke($class, Event::preRemoveTranslation, $document, new LifecycleEventArgs($document, $this->dm), $invoke);
}
$metadata = $this->dm->getClassMetadata(get_class($document));
if (!$this->isDocumentTranslatable($metadata)) {
return;
}
if (1 === count($this->getLocalesFor($document))) {
throw new PHPCRException('The last translation of a translatable document may not be removed');
}
if ($document instanceof Proxy) {
$document->__load();
}
$oid = spl_object_hash($document);
$this->documentTranslations[$oid][$locale] = null;
$this->setLocale($document, $metadata, null);
}