3
* $Id: Exception.php 5300 2008-12-17 21:59:39Z jwage $
5
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17
* This software consists of voluntary contributions made by many individuals
18
* and is licensed under the LGPL. For more information, see
19
* <http://www.phpdoctrine.org>.
23
* Doctrine_Validator_Exception
26
* @subpackage Validator
27
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
28
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
29
* @link www.phpdoctrine.org
31
* @version $Revision: 5300 $
33
class Doctrine_Validator_Exception extends Doctrine_Exception implements Countable, IteratorAggregate
38
private $invalid = array();
41
* @param Doctrine_Validator $validator
43
public function __construct(array $invalid)
45
$this->invalid = $invalid;
46
parent::__construct($this->generateMessage());
49
public function getInvalidRecords()
51
return $this->invalid;
54
public function getIterator()
56
return new ArrayIterator($this->invalid);
59
public function count()
61
return count($this->invalid);
65
* Generate a message with all classes that have exceptions
67
private function generateMessage()
70
foreach ($this->invalid as $record) {
71
$message .= $record->getErrorStackAsString();
77
* This method will apply the value of the $function variable as a user_func
78
* to tall errorstack objects in the exception
80
* @param mixed Either string with function name or array with object,
81
* functionname. See call_user_func in php manual for more inforamtion
83
public function inspect($function)
85
foreach ($this->invalid as $record) {
86
call_user_func($function, $record->getErrorStack());
b'\\ No newline at end of file'