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