# Source for file Exception.php

Documentation is available at Exception.php

1. <?php
2. /*
3. * $Id: Exception.php 2041 2007-07-21 22:15:22Z meus $
4. *
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.
16. *
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.com>.
20. */
21. Doctrine::autoload('Doctrine_Exception');
22. /**
23. * Doctrine_Validator_Exception
24. *
25. * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
26. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
27. * @package Doctrine
28. * @category Object Relational Mapping
29. * @link www.phpdoctrine.com
30. * @since 1.0
31. * @version $Revision: 2041 $
32. */
33. class Doctrine_Validator_Exception extends Doctrine_Exception implements Countable, IteratorAggregate
34. {
35. /**
36. * @var array $invalid
37. */
38. private $invalid = array();
39. /**
40. * @param Doctrine_Validator $validator
41. */
42. public function __construct(array $invalid)
43. {
44. $this->invalid = $invalid;
45. parent::__construct($this->generateMessage());
46. }
48. public function getInvalidRecords()
49. {
50. return $this->invalid;
51. }
53. public function getIterator()
54. {
55. return new ArrayIterator($this->invalid);
56. }
58. public function count()
59. {
60. return count($this->invalid);
61. }
62. /**
63. * __toString
64. *
65. * @return string
66. */
67. public function __toString()
68. {
70. return parent::__toString();
71. }
73. private function generateMessage()
74. {
75. $message = "";
76. foreach ($this->invalid as $record){
77. $message .= "Validaton error in class " . get_class($record) . " ";
78. }
79. return $message;
80. }
82. }