Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer::__construct PHP Метод

__construct() публичный Метод

Constructor.
См. также: BaseDateTimeTransformer::formats for available format options
public __construct ( string $inputTimezone = null, string $outputTimezone = null, integer $dateFormat = null, integer $timeFormat = null, IntlDateFormatter $calendar = IntlDateFormatter::GREGORIAN, string $pattern = null )
$inputTimezone string The name of the input timezone
$outputTimezone string The name of the output timezone
$dateFormat integer The date format
$timeFormat integer The time format
$calendar IntlDateFormatter An \IntlDateFormatter instance
$pattern string A pattern to pass to \IntlDateFormatter
    public function __construct($inputTimezone = null, $outputTimezone = null, $dateFormat = null, $timeFormat = null, $calendar = \IntlDateFormatter::GREGORIAN, $pattern = null)
    {
        parent::__construct($inputTimezone, $outputTimezone);

        if (null === $dateFormat) {
            $dateFormat = \IntlDateFormatter::MEDIUM;
        }

        if (null === $timeFormat) {
            $timeFormat = \IntlDateFormatter::SHORT;
        }

        if (!in_array($dateFormat, self::$formats, true)) {
            throw new UnexpectedTypeException($dateFormat, implode('", "', self::$formats));
        }

        if (!in_array($timeFormat, self::$formats, true)) {
            throw new UnexpectedTypeException($timeFormat, implode('", "', self::$formats));
        }

        $this->dateFormat = $dateFormat;
        $this->timeFormat = $timeFormat;
        $this->calendar = $calendar;
        $this->pattern = $pattern;
    }