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);
    }
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);
    }
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 ) ; }
Bind the translatable fields of the document in the specified locale.

This method will update the field mapped to Locale if it does not match the $locale argument.

@param object $document the document to persist a translation of
@param string $locale   the locale this document currently has

@throws PHPCRException if the document is not translatable
Bind the translatable fields of the document in the specified locale .