/** * Update data to translate label * * @param TranslatableInterface $object * @param array $data */ public function update(TranslatableInterface $object, array $data) { foreach ($data as $localeCode => $label) { $object->setLocale($localeCode); $translation = $object->getTranslation(); $translation->setLabel($label); } }
function it_throws_an_exception_if_method_not_exists(TranslatableInterface $translatable, AttributeTranslation $english, AttributeTranslation $french, AttributeTranslation $german) { $translatable->getTranslations()->willReturn([$english, $french, $german]); $english->getLocale()->willReturn('en_US'); $english->getLabel()->willReturn('foo'); $french->getLocale()->willReturn('fr_FR'); $french->getLabel()->willReturn('bar'); $german->getLocale()->willReturn('de_DE'); $german->getLabel()->willReturn('baz'); $this->shouldThrow('\\LogicException')->duringNormalize($translatable, 'csv', ['locales' => [], 'property' => 'unknown_property']); }