/** * {@inheritdoc} */ public function denormalize($data, $class, $format = null, array $context = []) { $data = $this->valuesDenormalizer->denormalize($data, $class, $format, $context); if (null !== $data) { $data = $this->localizer->localize($data, $context); } return $data; }
/** * {@inheritdoc} */ public function denormalize($data, $class, $format = null, array $context = []) { $metric = $this->metricDenormalizer->denormalize($data, $class, $format, $context); if (null !== $metric) { $metric->setData($this->localizer->localize($metric->getData(), $context)); } return $metric; }
/** * {@inheritdoc} */ protected function convertValue($value) { $result = $this->getBackendData($value); $data = isset($result['data']) ? $result['data'] : null; $unit = $result['unit']; if ($data && $unit) { $formattedData = $this->localizer->localize($data, ['locale' => $this->translator->getLocale()]); return $this->getTemplate()->render(['data' => $formattedData, 'unit' => $unit]); } }
/** * {@inheritdoc} */ public function normalize($price, $format = null, array $context = []) { $price = $this->priceNormalizer->normalize($price, $format, $context); foreach ($price as $currency => $data) { $formattedPrice = [['currency' => $currency, 'data' => $data]]; $localizedPrice = $this->localizer->localize($formattedPrice, $context); $price[$currency] = $localizedPrice[0]['data']; } return $price; }
/** * {@inheritdoc} */ public function denormalize($data, $class, $format = null, array $context = []) { $prices = $this->priceDenormalizer->denormalize($data, $class, $format, $context); if (null !== $prices) { foreach ($prices as $price) { $price->setData($this->localizer->localize($price->getData(), $context)); } } return $prices; }
/** * {@inheritdoc} */ public function normalize($metric, $format = null, array $context = []) { $metric = $this->metricNormalizer->normalize($metric, $format, $context); if (!isset($context['field_name']) || !isset($metric[$context['field_name']])) { return $metric; } $formattedMetric = ['data' => $metric[$context['field_name']]]; $localizedMetric = $this->localizer->localize($formattedMetric, $context); $metric[$context['field_name']] = $localizedMetric['data']; return $metric; }
/** * {@inheritdoc} */ protected function convertValue($value) { $data = $this->getBackendData($value); $prices = []; foreach ($data as $price) { if (isset($price['data']) && $price['data'] !== null) { $formattedPrice = $this->localizer->localize($price['data'], ['locale' => $this->translator->getLocale()]); $prices[] = sprintf('%s %s', $formattedPrice, Intl::getCurrencyBundle()->getCurrencySymbol($price['currency'])); } } return implode(', ', $prices); }
/** * {@inheritdoc} */ public function normalize($price, $format = null, array $context = []) { $price = $this->priceNormalizer->normalize($price, $format, $context); $price['data'] = $this->localizer->localize($price['data'], $context); return $price; }
/** * Return the number provided. Do nothing because number is still formatted by denormalizer * * @param string $number * * @return string */ public function transform($number) { return $this->localizer->localize($number, $this->options); }
/** * {@inheritdoc} */ public function normalize($metric, $format = null, array $context = []) { $metric = $this->metricNormalizer->normalize($metric, $format, $context); $metric['data'] = $this->localizer->localize($metric['data'], $context); return $metric; }
/** * {@inheritdoc} */ protected function convertValue($value) { $result = $this->getBackendData($value); return $this->localizer->localize($result, ['locale' => $this->translator->getLocale()]); }