Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function initialize(array $options)
 {
     if (empty($options['date'])) {
         // as a default value should be used local timezone date
         $localDate = new \DateTime(null, new \DateTimeZone($this->localeSettings->getTimeZone()));
         $options['date'] = $localDate->format('Y-m-d');
     } elseif (!is_string($options['date'])) {
         throw new InvalidParameterException(sprintf('Option "date" must be a string, %s given.', $this->getClassOrType($options['date'])));
     }
     return parent::initialize($options);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function initialize(array $options)
 {
     if (empty($options['time'])) {
         $options['time'] = null;
     } elseif (!is_string($options['time'])) {
         throw new InvalidParameterException(sprintf('Option "time" must be a string, %s given.', $this->getClassOrType($options['time'])));
     }
     if (empty($options['timezone'])) {
         $options['timezone'] = new \DateTimeZone('UTC');
     } elseif (is_string($options['timezone'])) {
         $options['timezone'] = new \DateTimeZone($options['timezone']);
     } elseif (!$options['timezone'] instanceof \DateTimeZone) {
         throw new InvalidParameterException(sprintf('Option "timezone" must be a string or instance of DateTimeZone, %s given.', $this->getClassOrType($options['timezone'])));
     }
     return parent::initialize($options);
 }