Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / lib / Doctrine / ORM / ORMException.php
1 <?php
2 /*
3  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * This software consists of voluntary contributions made by many individuals
16  * and is licensed under the MIT license. For more information, see
17  * <http://www.doctrine-project.org>.
18  */
19
20 namespace Doctrine\ORM;
21
22 use Exception;
23
24 /**
25  * Base exception class for all ORM exceptions.
26  *
27  * @author Roman Borschel <roman@code-factory.org>
28  * @since 2.0
29  */
30 class ORMException extends Exception
31 {
32     public static function missingMappingDriverImpl()
33     {
34         return new self("It's a requirement to specify a Metadata Driver and pass it ".
35             "to Doctrine\\ORM\\Configuration::setMetadataDriverImpl().");
36     }
37
38     public static function namedQueryNotFound($queryName)
39     {
40         return new self('Could not find a named query by the name "' . $queryName . '"');
41     }
42
43     public static function namedNativeQueryNotFound($nativeQueryName)
44     {
45         return new self('Could not find a named native query by the name "' . $nativeQueryName . '"');
46     }
47
48     public static function entityMissingForeignAssignedId($entity, $relatedEntity)
49     {
50         return new self(
51             "Entity of type " . get_class($entity) . " has identity through a foreign entity " . get_class($relatedEntity) . ", " .
52             "however this entity has no identity itself. You have to call EntityManager#persist() on the related entity " .
53             "and make sure that an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " .
54             "of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call " .
55             "EntityManager#flush() between both persist operations."
56         );
57     }
58
59     public static function entityMissingAssignedIdForField($entity, $field)
60     {
61         return new self("Entity of type " . get_class($entity) . " is missing an assigned ID for field  '" . $field . "'. " .
62             "The identifier generation strategy for this entity requires the ID field to be populated before ".
63             "EntityManager#persist() is called. If you want automatically generated identifiers instead " .
64             "you need to adjust the metadata mapping accordingly."
65         );
66     }
67
68     public static function unrecognizedField($field)
69     {
70         return new self("Unrecognized field: $field");
71     }
72
73     /**
74      * @param string $className
75      * @param string $field
76      */
77     public static function invalidOrientation($className, $field)
78     {
79         return new self("Invalid order by orientation specified for " . $className . "#" . $field);
80     }
81
82     public static function invalidFlushMode($mode)
83     {
84         return new self("'$mode' is an invalid flush mode.");
85     }
86
87     public static function entityManagerClosed()
88     {
89         return new self("The EntityManager is closed.");
90     }
91
92     public static function invalidHydrationMode($mode)
93     {
94         return new self("'$mode' is an invalid hydration mode.");
95     }
96
97     public static function mismatchedEventManager()
98     {
99         return new self("Cannot use different EventManager instances for EntityManager and Connection.");
100     }
101
102     public static function findByRequiresParameter($methodName)
103     {
104         return new self("You need to pass a parameter to '".$methodName."'");
105     }
106
107     public static function invalidFindByCall($entityName, $fieldName, $method)
108     {
109         return new self(
110             "Entity '".$entityName."' has no field '".$fieldName."'. ".
111             "You can therefore not call '".$method."' on the entities' repository"
112         );
113     }
114
115     public static function invalidFindByInverseAssociation($entityName, $associationFieldName)
116     {
117         return new self(
118             "You cannot search for the association field '".$entityName."#".$associationFieldName."', ".
119             "because it is the inverse side of an association. Find methods only work on owning side associations."
120         );
121     }
122
123     public static function invalidResultCacheDriver() {
124         return new self("Invalid result cache driver; it must implement Doctrine\\Common\\Cache\\Cache.");
125     }
126
127     public static function notSupported() {
128         return new self("This behaviour is (currently) not supported by Doctrine 2");
129     }
130
131     public static function queryCacheNotConfigured()
132     {
133         return new self('Query Cache is not configured.');
134     }
135
136     public static function metadataCacheNotConfigured()
137     {
138         return new self('Class Metadata Cache is not configured.');
139     }
140
141     public static function proxyClassesAlwaysRegenerating()
142     {
143         return new self('Proxy Classes are always regenerating.');
144     }
145
146     public static function unknownEntityNamespace($entityNamespaceAlias)
147     {
148         return new self(
149             "Unknown Entity namespace alias '$entityNamespaceAlias'."
150         );
151     }
152
153     public static function invalidEntityRepository($className)
154     {
155         return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository.");
156     }
157
158     public static function missingIdentifierField($className, $fieldName)
159     {
160         return new self("The identifier $fieldName is missing for a query of " . $className);
161     }
162
163     public static function overwriteInternalDQLFunctionNotAllowed($functionName)
164     {
165         return new self("It is not allowed to overwrite internal function '$functionName' in the DQL parser through user-defined functions.");
166     }
167 }