public function bindTranslation($document, $locale)
{
$state = $this->getDocumentState($document);
if ($state !== self::STATE_MANAGED) {
throw new InvalidArgumentException('Document has to be managed to be able to bind a translation ' . self::objToStr($document, $this->dm));
}
$class = $this->dm->getClassMetadata(get_class($document));
if (!$this->isDocumentTranslatable($class)) {
throw new PHPCRException('This document is not translatable, do not use bindTranslation: ' . self::objToStr($document, $this->dm));
}
if ($this->getCurrentLocale($document) != $locale && false !== array_search($locale, $this->getLocalesFor($document))) {
throw new RuntimeException(sprintf('Translation "%s" already exists for "%s". First load this translation if you want to change it, or remove the existing translation.', $locale, self::objToStr($document, $this->dm)));
}
$this->doBindTranslation($document, $locale, $class);
}