private function updateObjectTranslations(EntityManagerInterface $entityManager, $object): void
    {
        $translatableMeta = $this->getTranslatableMetadata($entityManager, $object);
        if (!$translatableMeta->hasTranslatableProperties()) {
            return;
        }

        foreach ($translatableMeta->getTranslationAssociationMetadatas() as $associationMeta) {
            $context = $this->getTranslationContext($entityManager, $associationMeta, $object);
            $locale = $this->translationHelper->getObjectLocale($context, $object);
            if (is_null($locale) || $locale === '') {
                $locale = $this->getLocale();
            }

            $hasTranslatedProperties = $this->translationHelper->hasTranslatedProperties($context, $object);
            if (!isset($locale) && $hasTranslatedProperties) {
                throw new Exception\RuntimeException(
                    "Neither object's locale nor the current locale was set for translatable properties"
                );
            }

            if ($hasTranslatedProperties) {
                $this->translationHelper->copyPropertiesToTranslation(
                    $context,
                    $object,
                    $locale
                );
            } else {
                $this->translationHelper->removeEmptyTranslation($context, $object);
            }
        }
    }
private function updateObjectTranslations(EntityManagerInterface $entityManager, $object): void
    {
        $translatableMeta = $this->getTranslatableMetadata($entityManager, $object);
        if (!$translatableMeta->hasTranslatableProperties()) {
            return;
        }

        foreach ($translatableMeta->getTranslationAssociationMetadatas() as $associationMeta) {
            $context = $this->getTranslationContext($entityManager, $associationMeta, $object);
            $locale = $this->translationHelper->getObjectLocale($context, $object);
            if (is_null($locale) || $locale === '') {
                $locale = $this->getLocale();
            }

            $hasTranslatedProperties = $this->translationHelper->hasTranslatedProperties($context, $object);
            if (!isset($locale) && $hasTranslatedProperties) {
                throw new Exception\RuntimeException(
                    "Neither object's locale nor the current locale was set for translatable properties"
                );
            }

            if ($hasTranslatedProperties) {
                $this->translationHelper->copyPropertiesToTranslation(
                    $context,
                    $object,
                    $locale
                );
            } else {
                $this->translationHelper->removeEmptyTranslation($context, $object);
            }
        }
    }
private function updateObjectTranslations ( EntityManagerInterface $ entityManager , $ object ) : void { $ translatableMeta = $ this -> getTranslatableMetadata ( $ entityManager , $ object ) ; if ( ! $ translatableMeta -> hasTranslatableProperties ( ) ) { return ; } foreach ( $ translatableMeta -> getTranslationAssociationMetadatas ( ) as $ associationMeta ) { $ context = $ this -> getTranslationContext ( $ entityManager , $ associationMeta , $ object ) ; $ locale = $ this -> translationHelper -> getObjectLocale ( $ context , $ object ) ; if ( is_null ( $ locale ) || $ locale === '' ) { $ locale = $ this -> getLocale ( ) ; } $ hasTranslatedProperties = $ this -> translationHelper -> hasTranslatedProperties ( $ context , $ object ) ; if ( ! isset ( $ locale ) && $ hasTranslatedProperties ) { throw new Exception \ RuntimeException ( "Neither object's locale nor the current locale was set for translatable properties" ) ; } if ( $ hasTranslatedProperties ) { $ this -> translationHelper -> copyPropertiesToTranslation ( $ context , $ object , $ locale ) ; } else { $ this -> translationHelper -> removeEmptyTranslation ( $ context , $ object ) ; } } }
Helper method to insert, remove or update translations entities associated
with specified object.

@param EntityManagerInterface $entityManager
@param object $object
@return void
@throws Exception\RuntimeException
Helper method to insert remove or update translations entities associated with specified object .