コード例 #1
0
 public function castValue($value)
 {
     $adjustedValue = parent::castValue($value);
     if (!isset($adjustedValue)) {
         return NULL;
     }
     if (is_bool($adjustedValue)) {
         // do nothing. It is already correct type
     } else {
         $result = $this->testValue($adjustedValue);
         if (isset($result)) {
             $adjustedValue = $result;
         } else {
             throw new IllegalArgumentException(t('Incorrect value of type BOOLEAN: @value', array('@value' => $adjustedValue)));
         }
     }
     return $adjustedValue;
 }
コード例 #2
0
 public function castValue($value)
 {
     $adjustedValue = parent::castValue($value);
     if (!isset($adjustedValue)) {
         return NULL;
     }
     // do not use procedural style. We need an exception in case of error
     try {
         $dt = new DateTime($adjustedValue);
     } catch (Exception $e) {
         LogHelper::log_error($e);
         throw new IllegalArgumentException(t('Failed to parse date and/or time string: @value', array('@value' => $adjustedValue)));
     }
     return $dt->format($this->getMask());
 }