/** * Presents an attribute option * * @param string $value * @param string $optionName * * @return string|null */ public function attributeOptionPresenter($value, $optionName) { $presenter = $this->presenterRegistry->getAttributeOptionPresenter($optionName); if (null !== $presenter) { $locale = $this->localeResolver->getCurrentLocale(); if (null !== $locale) { return $presenter->present($value, ['locale' => $locale]); } } return $value; }
/** * Localize the changeset values * * @param array $changeset * @param array $context * * @return array */ protected function convertChangeset(array $changeset, array $context) { foreach ($changeset as $attribute => $changes) { $context['versioned_attribute'] = $attribute; $attributeName = $attribute; if (preg_match('/^(?<attribute>[a-zA-Z0-9_]+)-.+$/', $attribute, $matches)) { $attributeName = $matches['attribute']; } $presenter = $this->presenterRegistry->getPresenterByAttributeCode($attributeName); if (null !== $presenter) { foreach ($changes as $key => $value) { $changeset[$attribute][$key] = $presenter->present($value, $context); } } } return $changeset; }