/** * {@inheritdoc} */ public function buildType(FieldConfigInterface $config, array $options) { $config->setValueComparison($this->valueComparison); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_RANGE, true); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_COMPARISON, true); $config->addViewTransformer(new MoneyToLocalizedStringTransformer($options['precision'], $options['grouping'], null, $options['divisor'], $options['default_currency'])); }
/** * {@inheritdoc} */ public function buildType(FieldConfigInterface $config, array $options) { $config->setValueComparison($this->valueComparison); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_RANGE, true); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_COMPARISON, true); $config->addViewTransformer(new IntegerToLocalizedStringTransformer($options['precision'], $options['grouping'], $options['rounding_mode'])); }
/** * {@inheritdoc} */ public function buildType(FieldConfigInterface $config, array $options) { $config->setValueComparison($this->valueComparison); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_RANGE, true); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_COMPARISON, true); $viewTransformers = $config->getViewTransformers(); $config->resetViewTransformers(); $config->addViewTransformer(new BirthdayTransformer($viewTransformers, $options['allow_age'], $options['allow_future_date'])); }
/** * {@inheritdoc} */ public function buildType(FieldConfigInterface $config, array $options) { $config->setValueComparison($this->valueComparison); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_RANGE, true); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_COMPARISON, true); $dateFormat = is_int($options['format']) ? $options['format'] : self::DEFAULT_FORMAT; $timeFormat = \IntlDateFormatter::NONE; $calendar = \IntlDateFormatter::GREGORIAN; $format = is_string($options['format']) ? $options['format'] : null; if (!in_array($dateFormat, self::$acceptedFormats, true)) { throw new InvalidConfigurationException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) ' . 'or a string representing a custom format.'); } if (null !== $format && (false === strpos($format, 'y') || false === strpos($format, 'M') || false === strpos($format, 'd'))) { throw new InvalidConfigurationException(sprintf('The "format" option should contain the letters "y", "M" and "d". Its current value is "%s".', $format)); } $config->addViewTransformer(new DateTimeToLocalizedStringTransformer('UTC', 'UTC', $dateFormat, $timeFormat, $calendar, $format)); }
/** * {@inheritdoc} */ public function buildType(FieldConfigInterface $config, array $options) { $format = 'H'; if ($options['with_seconds'] && !$options['with_minutes']) { throw new InvalidConfigurationException('You can not disable minutes if you have enabled seconds.'); } if ($options['with_minutes']) { $format .= ':i'; } if ($options['with_seconds']) { $format .= ':s'; } $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_RANGE, true); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_COMPARISON, true); $config->setValueComparison($this->valueComparison); $config->addViewTransformer(new DateTimeToStringTransformer('UTC', 'UTC', $format)); }
/** * {@inheritdoc} */ public function buildType(FieldConfigInterface $config, array $options) { $config->setValueComparison($this->valueComparison); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_RANGE, true); $config->setValueTypeSupport(ValuesBag::VALUE_TYPE_COMPARISON, true); if ($options['pattern']) { $options['format'] = $options['pattern']; } if (null === $options['format']) { if (!in_array($options['date_format'], self::$acceptedFormats, true)) { throw new InvalidConfigurationException('The "date_format" option must be one of the IntlDateFormatter constants ' . '(FULL, LONG, MEDIUM, SHORT) or the "format" must be a string representing a custom format.'); } if (!in_array($options['time_format'], self::$acceptedFormats, true)) { throw new InvalidConfigurationException('The "time_format" option must be one of the IntlDateFormatter constants ' . '(FULL, LONG, MEDIUM, SHORT) or the "format" must be a string representing a custom format.'); } } if (self::HTML5_FORMAT === $options['format']) { $config->addViewTransformer(new DateTimeToRfc3339Transformer($options['model_timezone'], $options['view_timezone'])); } else { $config->addViewTransformer(new DateTimeToLocalizedStringTransformer($options['model_timezone'], $options['view_timezone'], $options['date_format'], $options['time_format'], \IntlDateFormatter::GREGORIAN, $options['format'])); } }
/** * {@inheritdoc} */ public function buildType(FieldConfigInterface $config, array $options) { $config->setValueComparison($this->valueComparison); }