protected function _getValidationCodesRec(&$codes, $key, $msg, $name = '')
 {
     if (is_array($msg)) {
         $name = empty($name) ? $key : "{$name}.{$key}";
         foreach ($msg as $k => $v) {
             $this->_getValidationCodesRec($codes, $k, $v, $name);
         }
     } else {
         if (ValidationCodes::hasCode($key)) {
             $name = empty($name) ? self::GLOBAL_ERROR : $name;
             $codes[$name] = ValidationCodes::getCode($key);
         } else {
             $codes[$name] = ValidationCodes::INVALID_VALUE;
             \App::log()->warn("Missing {$key} validation code");
         }
     }
 }
Пример #2
0
 public function changeBillingCycleStartDay($orgId, $billingId, $day)
 {
     $validator = new Validate\OrgChangeBillingDayValidate();
     $ok = $validator->isValid(array('id' => $orgId, 'billingAccountId' => $billingId, 'billingCycleStartDay' => $day));
     if ($ok) {
         $mapper = $this->getMapperByType($this->getTypeById($orgId));
         return $mapper->changeBillingCycleStartDay($orgId, $billingId, $day);
     } else {
         $code = 0;
         foreach ($validator->getMessages() as $valCode => $message) {
             if ($n = ValidationCodes::getCode($valCode)) {
                 $code = $n;
                 break;
             }
         }
         throw new ValidateException("Billing account {$billingId} cycle is not modifiable", array('code' => $code, 'validationErrors' => $validator->getMessages()));
     }
 }