Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function convertDefaultToLocalizedFromLocale($date, $locale)
 {
     if (null === $date || '' === $date) {
         return $date;
     }
     $format = $this->formatProvider->getFormat($locale);
     $datetime = new \DateTime();
     $datetime = $datetime->createFromFormat(static::DEFAULT_DATE_FORMAT, $date);
     return $datetime->format($format);
 }
 /**
  * {@inheritdoc}
  */
 public function validate($number, array $options = [], $attributeCode)
 {
     if (null === $number || '' === $number) {
         return null;
     }
     $options = $this->getOptions($options);
     if (isset($options['locale']) && !isset($options['decimal_separator'])) {
         $options['decimal_separator'] = $this->formatProvider->getFormat($options['locale'])['decimal_separator'];
     }
     $constraint = new NumberFormat();
     $constraint->decimalSeparator = $options['decimal_separator'];
     $constraint->path = $attributeCode;
     return $this->validator->validate($number, $constraint);
 }
 /**
  * @return array
  */
 public function getFormats()
 {
     $locale = $this->getCurrentLocale();
     return ['decimal_separator' => $this->numberFormatProvider->getFormat($locale)['decimal_separator'], 'date_format' => $this->dateFactory->create(['locale' => $locale])->getPattern()];
 }
 /**
  * @param string $uiLocale
  */
 public function configureOptions($uiLocale)
 {
     $this->decimalSeparator = $this->numberFormatProvider->getFormat($uiLocale)['decimal_separator'];
     $this->dateFormat = $this->dateFormatProvider->getFormat($uiLocale);
 }
 /**
  * @return array
  */
 public function getFormats()
 {
     $locale = $this->getCurrentLocale();
     return ['decimal_separator' => $this->numberFormatProvider->getFormat($locale)['decimal_separator'], 'date_format' => $this->dateFormatProvider->getFormat($locale)];
 }