コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function setValue($value)
 {
     if (!is_bool($value) && $value !== null) {
         throw new \InvalidArgumentException(sprintf('The option "%s" only accepts boolean value.', $this->getName()));
     }
     parent::setValue($value);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function setValue($value)
 {
     if (is_string($value)) {
         try {
             $value = new \DateTime($value);
         } catch (\Exception $e) {
             throw new \InvalidArgumentException($e->getMessage());
         }
     }
     if (!$value instanceof \DateTime && $value !== null) {
         throw new \InvalidArgumentException(sprintf('The option "%s" only accepts \\DateTime objects or strings.', $this->getName()));
     }
     parent::setValue($value);
 }