コード例 #1
0
 /**
  * {@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;
 }
コード例 #2
0
 /**
  * {@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;
 }
コード例 #3
0
 /**
  * {@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]);
     }
 }
コード例 #4
0
 /**
  * {@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;
 }
コード例 #5
0
 /**
  * {@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;
 }
コード例 #6
0
 /**
  * {@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;
 }
コード例 #7
0
 /**
  * {@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);
 }
コード例 #8
0
 /**
  * {@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;
 }
コード例 #9
0
 /**
  * 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);
 }
コード例 #10
0
 /**
  * {@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;
 }
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 protected function convertValue($value)
 {
     $result = $this->getBackendData($value);
     return $this->localizer->localize($result, ['locale' => $this->translator->getLocale()]);
 }