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 = [];
            }
        } else {
            $locales = [];
        }

        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;
    }
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 = [];
            }
        } else {
            $locales = [];
        }

        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;
    }
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 = [ ] ; } } else { $ locales = [ ] ; } 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 ; }
Get all locales in which this document currently exists in storage.

@param object $document A managed document

@throws MissingTranslationException if this document is not translatable

@return array list of locales of this document
Get all locales in which this document currently exists in storage .