~patrix-sbs/oraculum/git

« back to all changes in this revision

Viewing changes to library/components/doctrine/lib/Doctrine/Validator/Exception.php

  • Committer: Patrick Kaminski
  • Date: 2009-09-02 02:33:07 UTC
  • Revision ID: git-v1:943803254fca67bfb4c0374422b1b836b14dc518
Tags: v0.1a
Sending Oraculum Framework v0.1 alpha

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 *  $Id: Exception.php 5300 2008-12-17 21:59:39Z jwage $
 
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.org>.
 
20
 */
 
21
 
 
22
/**
 
23
 * Doctrine_Validator_Exception
 
24
 *
 
25
 * @package     Doctrine
 
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
 
30
 * @since       1.0
 
31
 * @version     $Revision: 5300 $
 
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
    /**
 
41
     * @param Doctrine_Validator $validator
 
42
     */
 
43
    public function __construct(array $invalid)
 
44
    {
 
45
        $this->invalid = $invalid;
 
46
        parent::__construct($this->generateMessage());
 
47
    }
 
48
 
 
49
    public function getInvalidRecords()
 
50
    {
 
51
        return $this->invalid;
 
52
    }
 
53
 
 
54
    public function getIterator()
 
55
    {
 
56
        return new ArrayIterator($this->invalid);
 
57
    }
 
58
 
 
59
    public function count()
 
60
    {
 
61
        return count($this->invalid);
 
62
    }
 
63
 
 
64
    /**
 
65
     * Generate a message with all classes that have exceptions
 
66
     */
 
67
    private function generateMessage()
 
68
    {
 
69
        $message = '';
 
70
        foreach ($this->invalid as $record) {
 
71
            $message .= $record->getErrorStackAsString();
 
72
        }
 
73
        return $message;
 
74
    }
 
75
 
 
76
    /**
 
77
     * This method will apply the value of the $function variable as a user_func 
 
78
     * to tall errorstack objects in the exception
 
79
     *
 
80
     * @param mixed Either string with function name or array with object, 
 
81
     * functionname. See call_user_func in php manual for more inforamtion
 
82
     */
 
83
    public function inspect($function)
 
84
    {
 
85
        foreach ($this->invalid as $record) {
 
86
            call_user_func($function, $record->getErrorStack());
 
87
        }
 
88
    }
 
89
}
 
 
b'\\ No newline at end of file'