/** * Record errors posted in the subject instance for display in the form. Once processed errors are cleared from the subject. * * @param BundlableLabelableBaseModelWithAttributes $pt_subject * @param array $pa_response_data An array containing the JSON response for the form; errors should be inserted into this array for later display * @param int $pn_num_errors The error count * * @return int The number of errors processed */ private function _checkErrors($pt_subject, &$pa_response_data, &$pn_num_errors) { $vn_c = 0; if ($pt_subject->numErrors()) { foreach ($pt_subject->errors as $o_error) { if (!($vs_source = $o_error->getErrorSource())) { $vs_source = '_general_'; } if (!is_array($pa_response_data['errors'][$vs_source])) { $pa_response_data['errors'][$vs_source] = array(); } if (!in_array($vs_error_desc = $o_error->getErrorDescription(), $pa_response_data['errors'][$vs_source])) { $pa_response_data['errors'][$vs_source][] = $vs_error_desc; $pn_num_errors++; $vn_c++; } } $pt_subject->clearErrors(); } return $vn_c; }