function it_should_assign_current_and_default_locale_to_given_translatable_entity(TranslationLocaleProviderInterface $translationLocaleProvider, TranslatableInterface $translatableEntity)
 {
     $translationLocaleProvider->getDefaultLocaleCode()->willReturn('en_US');
     $translatableEntity->setCurrentLocale('en_US')->shouldBeCalled();
     $translatableEntity->setFallbackLocale('en_US')->shouldBeCalled();
     $this->assignLocale($translatableEntity);
 }
 function it_should_use_default_locale_as_current_if_could_not_resolve_the_current_locale(LocaleContextInterface $localeContext, TranslationLocaleProviderInterface $translationLocaleProvider, TranslatableInterface $translatableEntity)
 {
     $localeContext->getLocaleCode()->willThrow(new LocaleNotFoundException());
     $translationLocaleProvider->getDefaultLocaleCode()->willReturn('en_US');
     $translatableEntity->setCurrentLocale('en_US')->shouldBeCalled();
     $translatableEntity->setFallbackLocale('en_US')->shouldBeCalled();
     $this->assignLocale($translatableEntity);
 }
Пример #3
0
 function its_detaches_from_its_translatable_correctly(TranslatableInterface $translatable1, TranslatableInterface $translatable2)
 {
     $translatable1->addTranslation(Argument::type(AbstractTranslation::class));
     $this->setTranslatable($translatable1);
     $translatable1->removeTranslation(Argument::type(AbstractTranslation::class));
     $translatable2->addTranslation(Argument::type(AbstractTranslation::class));
     $this->setTranslatable($translatable2);
 }
 /**
  * {@inheritdoc}
  */
 public function assignLocale(TranslatableInterface $translatableEntity)
 {
     $fallbackLocale = $this->translationLocaleProvider->getDefaultLocaleCode();
     try {
         $currentLocale = $this->localeContext->getLocaleCode();
     } catch (LocaleNotFoundException $e) {
         $currentLocale = $fallbackLocale;
     }
     $translatableEntity->setCurrentLocale($currentLocale);
     $translatableEntity->setFallbackLocale($fallbackLocale);
 }
 /**
  * {@inheritdoc}
  */
 public function assignLocale(TranslatableInterface $translatableEntity)
 {
     $localeCode = $this->translationLocaleProvider->getDefaultLocaleCode();
     $translatableEntity->setCurrentLocale($localeCode);
     $translatableEntity->setFallbackLocale($localeCode);
 }