/** * @param string $name * * @return string */ protected function getPropertyName($name) { if (in_array($name, $this->translatableFields, true)) { return 'translations.' . $this->localeProvider->getDefaultLocaleCode() . '.' . $name; } return $name; }
/** * {@inheritdoc} * * @throws UnexpectedTypeException */ public function createNew() { $resource = $this->factory->createNew(); if (!$resource instanceof TranslatableInterface) { throw new UnexpectedTypeException($resource, TranslatableInterface::class); } $resource->setCurrentLocale($this->localeProvider->getDefaultLocaleCode()); $resource->setFallbackLocale($this->localeProvider->getDefaultLocaleCode()); return $resource; }
function it_creates_translatable_and_sets_locales(FactoryInterface $factory, TranslationLocaleProviderInterface $localeProvider, TranslatableInterface $resource) { $localeProvider->getDefaultLocaleCode()->willReturn('pl_PL'); $factory->createNew()->willReturn($resource); $resource->setCurrentLocale('pl_PL')->shouldBeCalled(); $resource->setFallbackLocale('pl_PL')->shouldBeCalled(); $this->createNew()->shouldReturn($resource); }
/** * @param TranslationLocaleProviderInterface $localeProvider */ public function __construct(TranslationLocaleProviderInterface $localeProvider) { $this->definedLocalesCodes = $localeProvider->getDefinedLocalesCodes(); $this->defaultLocaleCode = $localeProvider->getDefaultLocaleCode(); }