/**
  * @param string $name
  *
  * @return string
  */
 protected function getPropertyName($name)
 {
     if (in_array($name, $this->translatableFields)) {
         return 'translations.' . $this->localeProvider->getCurrentLocale() . '.' . $name;
     }
     return $name;
 }
 function it_throws_an_exception_if_locale_taken_from_storage_is_not_available(ChannelContextInterface $channelContext, LocaleStorageInterface $localeStorage, LocaleProviderInterface $localeProvider, ChannelInterface $channel)
 {
     $channelContext->getChannel()->willReturn($channel);
     $localeStorage->get($channel)->willReturn('pl_PL');
     $localeProvider->getAvailableLocalesCodes()->willReturn(['en_US', 'en_UK']);
     $this->shouldThrow(LocaleNotFoundException::class)->during('getLocaleCode');
 }
 function it_creates_translatable_and_sets_locales(FactoryInterface $factory, LocaleProviderInterface $localeProvider, SampleTranslatableResource $resource)
 {
     $localeProvider->getCurrentLocale()->willReturn('pl_PL');
     $localeProvider->getFallbackLocale()->willReturn('en_GB');
     $factory->createNew()->willReturn($resource);
     $resource->setCurrentLocale('pl_PL')->shouldBeCalled();
     $resource->setFallbackLocale('en_GB')->shouldBeCalled();
     $this->createNew()->shouldReturn($resource);
 }
 /**
  * {@inheritdoc}
  */
 public function createNew()
 {
     $resource = $this->factory->createNew();
     if (!$resource instanceof TranslatableInterface) {
         throw new UnexpectedTypeException($resource, TranslatableInterface::class);
     }
     $resource->setCurrentLocale($this->localeProvider->getCurrentLocale());
     $resource->setFallbackLocale($this->localeProvider->getFallbackLocale());
     return $resource;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $locales = $this->availableLocalesProvider->getAvailableLocales();
     $localesWithRequirement = [];
     foreach ($locales as $locale) {
         $localesWithRequirement[$locale] = false;
         if ($this->localeProvider->getDefaultLocale() === $locale) {
             $localesWithRequirement[$locale] = true;
             $localesWithRequirement = array_reverse($localesWithRequirement, true);
         }
     }
     $builder->addEventSubscriber(new ResourceTranslationsSubscriber($localesWithRequirement));
 }