Changeset 5300
- Timestamp:
- 12/17/08 21:59:39 (7 months ago)
- Location:
- branches
- Files:
-
- 2 added
- 4 modified
-
1.0/lib/Doctrine/Record.php (modified) (1 diff)
-
1.0/lib/Doctrine/Validator/Exception.php (modified) (1 diff)
-
1.0/tests/Ticket/1763TestCase.php (added)
-
1.1/lib/Doctrine/Record.php (modified) (1 diff)
-
1.1/lib/Doctrine/Validator/Exception.php (modified) (1 diff)
-
1.1/tests/Ticket/1763TestCase.php (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/lib/Doctrine/Record.php
r5264 r5300 454 454 public function preDqlDelete($event) 455 455 { } 456 457 /** 458 * Get the record error stack as a human readable string. 459 * Useful for outputting errors to user via web browser 460 * 461 * @return string $message 462 */ 463 public function getErrorStackAsString() 464 { 465 $errorStack = $this->getErrorStack(); 466 467 if (count($errorStack)) { 468 $message = sprintf("Validation failed in class %s\n\n", get_class($this)); 469 470 $message .= " " . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " had validation error" . (count($errorStack) > 1 ? 's' : null) . ":\n\n"; 471 foreach ($errorStack as $field => $errors) { 472 $message .= " * " . count($errors) . " validator" . (count($errors) > 1 ? 's' : null) . " failed on $field (" . implode(", ", $errors) . ")\n"; 473 } 474 return $message; 475 } else { 476 return false; 477 } 478 } 456 479 457 480 /** -
branches/1.0/lib/Doctrine/Validator/Exception.php
r5132 r5300 63 63 64 64 /** 65 * __toString66 *67 * @return string68 */69 public function __toString()70 {71 72 return parent::__toString();73 }74 75 /**76 65 * Generate a message with all classes that have exceptions 77 66 */ 78 67 private function generateMessage() 79 68 { 80 $message = "";69 $message = ''; 81 70 foreach ($this->invalid as $record) { 82 $message .= "Validation error in class " . get_class($record) . " ";71 $message .= $record->getErrorStackAsString(); 83 72 } 84 73 return $message; -
branches/1.1/lib/Doctrine/Record.php
r5264 r5300 505 505 public function postHydrate($event) 506 506 { } 507 508 /** 509 * Get the record error stack as a human readable string. 510 * Useful for outputting errors to user via web browser 511 * 512 * @return string $message 513 */ 514 public function getErrorStackAsString() 515 { 516 $errorStack = $this->getErrorStack(); 517 518 if (count($errorStack)) { 519 $message = sprintf("Validation failed in class %s\n\n", get_class($this)); 520 521 $message .= " " . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " had validation error" . (count($errorStack) > 1 ? 's' : null) . ":\n\n"; 522 foreach ($errorStack as $field => $errors) { 523 $message .= " * " . count($errors) . " validator" . (count($errors) > 1 ? 's' : null) . " failed on $field (" . implode(", ", $errors) . ")\n"; 524 } 525 return $message; 526 } else { 527 return false; 528 } 529 } 507 530 508 531 /** -
branches/1.1/lib/Doctrine/Validator/Exception.php
r5132 r5300 63 63 64 64 /** 65 * __toString66 *67 * @return string68 */69 public function __toString()70 {71 72 return parent::__toString();73 }74 75 /**76 65 * Generate a message with all classes that have exceptions 77 66 */ 78 67 private function generateMessage() 79 68 { 80 $message = "";69 $message = ''; 81 70 foreach ($this->invalid as $record) { 82 $message .= "Validation error in class " . get_class($record) . " ";71 $message .= $record->getErrorStackAsString(); 83 72 } 84 73 return $message;