public function getLocalesFor($document)
{
$metadata = $this->dm->getClassMetadata(get_class($document));
if (!$this->isDocumentTranslatable($metadata)) {
throw new MissingTranslationException('This document is not translatable: : ' . self::objToStr($document, $this->dm));
}
$oid = spl_object_hash($document);
if ($this->contains($oid)) {
try {
$node = $this->session->getNode($this->getDocumentId($document));
$locales = $this->dm->getTranslationStrategy($metadata->translator)->getLocalesFor($document, $node, $metadata);
} catch (PathNotFoundException $e) {
$locales = array();
}
} else {
$locales = array();
}
if (isset($this->documentTranslations[$oid])) {
foreach ($this->documentTranslations[$oid] as $locale => $value) {
if (!in_array($locale, $locales)) {
if ($value) {
$locales[] = $locale;
}
} elseif (!$value) {
$key = array_search($locale, $locales);
unset($locales[$key]);
}
}
$locales = array_values($locales);
}
return $locales;
}