From 11206fe57374264dd2451fb8d7e0585e5e604a38 Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 8 Oct 2006 18:20:10 +0000 Subject: [PATCH] Small fixes, now it should be possible to add custom errors --- lib/Doctrine/Record.php | 4 +++- lib/Doctrine/Validator/ErrorStack.php | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index d3271f9fb..c20737b19 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -834,7 +834,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $saveLater = $conn->saveRelated($this); - if( ! $this->isValid()) { + $this->isValid(); + + if($this->errorStack->count() > 0) { $conn->getTransaction()->addInvalid($this); } else { $conn->save($this); diff --git a/lib/Doctrine/Validator/ErrorStack.php b/lib/Doctrine/Validator/ErrorStack.php index 2cdf86dc8..9ad42222e 100644 --- a/lib/Doctrine/Validator/ErrorStack.php +++ b/lib/Doctrine/Validator/ErrorStack.php @@ -26,7 +26,7 @@ Doctrine::autoload('Doctrine_Access'); * @license LGPL * @package Doctrine */ -class Doctrine_Validator_ErrorStack extends Doctrine_Access { +class Doctrine_Validator_ErrorStack extends Doctrine_Access implements Countable, IteratorAggregate { private $errors = array(); @@ -42,8 +42,15 @@ class Doctrine_Validator_ErrorStack extends Doctrine_Access { return null; } - + public function set($name, $value) { - $this->errors[$name] = $value; + $this->errors[$name] = $value; + } + + public function getIterator() { + return new ArrayIterator($this->errors); + } + public function count() { + return count($this->errors); } }