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 LGPL. 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 entityMissingForeignAssignedId($entity, $relatedEntity) |
---|
39 | { |
---|
40 | return new self( |
---|
41 | "Entity of type " . get_class($entity) . " has identity through a foreign entity " . get_class($relatedEntity) . ", " . |
---|
42 | "however this entity has no identity itself. You have to call EntityManager#persist() on the related entity " . |
---|
43 | "and make sure that an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " . |
---|
44 | "of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call " . |
---|
45 | "EntityManager#flush() between both persist operations." |
---|
46 | ); |
---|
47 | } |
---|
48 | |
---|
49 | public static function entityMissingAssignedIdForField($entity, $field) |
---|
50 | { |
---|
51 | return new self("Entity of type " . get_class($entity) . " is missing an assigned ID for field '" . $field . "'. " . |
---|
52 | "The identifier generation strategy for this entity requires the ID field to be populated before ". |
---|
53 | "EntityManager#persist() is called. If you want automatically generated identifiers instead " . |
---|
54 | "you need to adjust the metadata mapping accordingly." |
---|
55 | ); |
---|
56 | } |
---|
57 | public static function unrecognizedField($field) |
---|
58 | { |
---|
59 | return new self("Unrecognized field: $field"); |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | * @param string $className |
---|
64 | * @param string $field |
---|
65 | */ |
---|
66 | public static function invalidOrientation($className, $field) |
---|
67 | { |
---|
68 | return new self("Invalid order by orientation specified for " . $className . "#" . $field); |
---|
69 | } |
---|
70 | |
---|
71 | public static function invalidFlushMode($mode) |
---|
72 | { |
---|
73 | return new self("'$mode' is an invalid flush mode."); |
---|
74 | } |
---|
75 | |
---|
76 | public static function entityManagerClosed() |
---|
77 | { |
---|
78 | return new self("The EntityManager is closed."); |
---|
79 | } |
---|
80 | |
---|
81 | public static function invalidHydrationMode($mode) |
---|
82 | { |
---|
83 | return new self("'$mode' is an invalid hydration mode."); |
---|
84 | } |
---|
85 | |
---|
86 | public static function mismatchedEventManager() |
---|
87 | { |
---|
88 | return new self("Cannot use different EventManager instances for EntityManager and Connection."); |
---|
89 | } |
---|
90 | |
---|
91 | public static function findByRequiresParameter($methodName) |
---|
92 | { |
---|
93 | return new self("You need to pass a parameter to '".$methodName."'"); |
---|
94 | } |
---|
95 | |
---|
96 | public static function invalidFindByCall($entityName, $fieldName, $method) |
---|
97 | { |
---|
98 | return new self( |
---|
99 | "Entity '".$entityName."' has no field '".$fieldName."'. ". |
---|
100 | "You can therefore not call '".$method."' on the entities' repository" |
---|
101 | ); |
---|
102 | } |
---|
103 | |
---|
104 | public static function invalidFindByInverseAssociation($entityName, $associationFieldName) |
---|
105 | { |
---|
106 | return new self( |
---|
107 | "You cannot search for the association field '".$entityName."#".$associationFieldName."', ". |
---|
108 | "because it is the inverse side of an association. Find methods only work on owning side associations." |
---|
109 | ); |
---|
110 | } |
---|
111 | |
---|
112 | public static function invalidResultCacheDriver() { |
---|
113 | return new self("Invalid result cache driver; it must implement \Doctrine\Common\Cache\Cache."); |
---|
114 | } |
---|
115 | |
---|
116 | public static function notSupported() { |
---|
117 | return new self("This behaviour is (currently) not supported by Doctrine 2"); |
---|
118 | } |
---|
119 | |
---|
120 | public static function queryCacheNotConfigured() |
---|
121 | { |
---|
122 | return new self('Query Cache is not configured.'); |
---|
123 | } |
---|
124 | |
---|
125 | public static function metadataCacheNotConfigured() |
---|
126 | { |
---|
127 | return new self('Class Metadata Cache is not configured.'); |
---|
128 | } |
---|
129 | |
---|
130 | public static function proxyClassesAlwaysRegenerating() |
---|
131 | { |
---|
132 | return new self('Proxy Classes are always regenerating.'); |
---|
133 | } |
---|
134 | |
---|
135 | public static function unknownEntityNamespace($entityNamespaceAlias) |
---|
136 | { |
---|
137 | return new self( |
---|
138 | "Unknown Entity namespace alias '$entityNamespaceAlias'." |
---|
139 | ); |
---|
140 | } |
---|
141 | |
---|
142 | public static function invalidEntityRepository($className) |
---|
143 | { |
---|
144 | return new self("Invalid repository class '".$className."'. ". |
---|
145 | "it must be a Doctrine\ORM\EntityRepository."); |
---|
146 | } |
---|
147 | |
---|
148 | public static function missingIdentifierField($className, $fieldName) |
---|
149 | { |
---|
150 | return new self("The identifier $fieldName is missing for a query of " . $className); |
---|
151 | } |
---|
152 | } |
---|