/**
  * @param string $name
  *
  * @return string
  */
 protected function getPropertyName($name)
 {
     if (in_array($name, $this->translatableFields)) {
         return 'translations.' . $this->localeProvider->getCurrentLocale() . '.' . $name;
     }
     return $name;
 }
Esempio n. 2
0
 /**
  * {@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;
 }
 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);
 }