src/Graviton/I18nBundle/Translator/Translator.php
public function persistTranslatable(Translatable $translatable)
    {
        $translations = $translatable->getTranslations();
        if (!isset($translations[$this->defaultLanguage])) {
            throw new \LogicException('Not possible to persist a Translatable without default language!');
        }

        $original = $translations[$this->defaultLanguage];
        unset($translations[$this->defaultLanguage]);

        foreach ($translations as $language => $translation) {
            $this->translationCollection->upsert(
                [
                    'original' => $original,
                    'language' => $language
                ],
                [
                    'original' => $original,
                    'language' => $language,
                    'localized' => $translation
                ]
            );
        }

        $this->removeFromCache($original);
    }
public function persistTranslatable(Translatable $translatable)
    {
        $translations = $translatable->getTranslations();
        if (!isset($translations[$this->defaultLanguage])) {
            throw new \LogicException('Not possible to persist a Translatable without default language!');
        }

        $original = $translations[$this->defaultLanguage];
        unset($translations[$this->defaultLanguage]);

        foreach ($translations as $language => $translation) {
            $this->translationCollection->upsert(
                [
                    'original' => $original,
                    'language' => $language
                ],
                [
                    'original' => $original,
                    'language' => $language,
                    'localized' => $translation
                ]
            );
        }

        $this->removeFromCache($original);
    }
public function persistTranslatable ( Translatable $ translatable ) { $ translations = $ translatable -> getTranslations ( ) ; if ( ! isset ( $ translations [ $ this -> defaultLanguage ] ) ) { throw new \ LogicException ( 'Not possible to persist a Translatable without default language!' ) ; } $ original = $ translations [ $ this -> defaultLanguage ] ; unset ( $ translations [ $ this -> defaultLanguage ] ) ; foreach ( $ translations as $ language => $ translation ) { $ this -> translationCollection -> upsert ( [ 'original' => $ original , 'language' => $ language ] , [ 'original' => $ original , 'language' => $ language , 'localized' => $ translation ] ) ; } $ this -> removeFromCache ( $ original ) ; }
persists a translatable to database

@param Translatable $translatable the translatable

@return void
persists a translatable to database