|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Doctrine\ORM; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Common\Cache\Cache as CacheDriver; |
|
8
|
|
|
use Exception; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Base exception class for all ORM exceptions. |
|
12
|
|
|
* |
|
13
|
|
|
* @author Roman Borschel <[email protected]> |
|
14
|
|
|
* @since 2.0 |
|
15
|
|
|
*/ |
|
16
|
|
|
class ORMException extends Exception |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @param string $field |
|
20
|
|
|
* |
|
21
|
|
|
* @return ORMException |
|
22
|
|
|
*/ |
|
23
|
|
|
public static function unrecognizedField($field) |
|
24
|
|
|
{ |
|
25
|
|
|
return new self("Unrecognized field: $field"); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* |
|
30
|
|
|
* @param string $class |
|
31
|
|
|
* @param string $association |
|
32
|
|
|
* @param string $given |
|
33
|
|
|
* @param string $expected |
|
34
|
|
|
* |
|
35
|
|
|
* @return \Doctrine\ORM\ORMInvalidArgumentException |
|
36
|
|
|
*/ |
|
37
|
|
|
public static function unexpectedAssociationValue($class, $association, $given, $expected) |
|
38
|
|
|
{ |
|
39
|
|
|
return new self(sprintf('Found entity of type %s on association %s#%s, but expecting %s', $given, $class, $association, $expected)); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param string $className |
|
44
|
|
|
* @param string $field |
|
45
|
|
|
* |
|
46
|
|
|
* @return ORMException |
|
47
|
2 |
|
*/ |
|
48
|
|
|
public static function invalidOrientation($className, $field) |
|
49
|
2 |
|
{ |
|
50
|
|
|
return new self("Invalid order by orientation specified for " . $className . "#" . $field); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return ORMException |
|
55
|
|
|
*/ |
|
56
|
|
|
public static function entityManagerClosed() |
|
57
|
|
|
{ |
|
58
|
|
|
return new self("The EntityManager is closed."); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param string $mode |
|
63
|
|
|
* |
|
64
|
|
|
* @return ORMException |
|
65
|
|
|
*/ |
|
66
|
|
|
public static function invalidHydrationMode($mode) |
|
67
|
|
|
{ |
|
68
|
|
|
return new self("'$mode' is an invalid hydration mode."); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return ORMException |
|
73
|
|
|
*/ |
|
74
|
|
|
public static function mismatchedEventManager() |
|
75
|
|
|
{ |
|
76
|
|
|
return new self("Cannot use different EventManager instances for EntityManager and Connection."); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return ORMException |
|
81
|
|
|
*/ |
|
82
|
|
|
public static function invalidResultCacheDriver() |
|
83
|
|
|
{ |
|
84
|
|
|
return new self("Invalid result cache driver; it must implement Doctrine\\Common\\Cache\\Cache."); |
|
85
|
1 |
|
} |
|
86
|
|
|
|
|
87
|
1 |
|
/** |
|
88
|
1 |
|
* @return ORMException |
|
89
|
1 |
|
*/ |
|
90
|
1 |
|
public static function notSupported() |
|
91
|
|
|
{ |
|
92
|
|
|
return new self("This behaviour is (currently) not supported by Doctrine 2"); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @return ORMException |
|
97
|
|
|
*/ |
|
98
|
|
|
public static function queryCacheNotConfigured() |
|
99
|
3 |
|
{ |
|
100
|
|
|
return new self('Query Cache is not configured.'); |
|
101
|
3 |
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return ORMException |
|
105
|
|
|
*/ |
|
106
|
|
|
public static function metadataCacheNotConfigured() |
|
107
|
|
|
{ |
|
108
|
|
|
return new self('Class Metadata Cache is not configured.'); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @param \Doctrine\Common\Cache\Cache $cache |
|
113
|
|
|
* |
|
114
|
|
|
* @return ORMException |
|
115
|
|
|
*/ |
|
116
|
|
|
public static function queryCacheUsesNonPersistentCache(CacheDriver $cache) |
|
117
|
|
|
{ |
|
118
|
|
|
return new self('Query Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @param \Doctrine\Common\Cache\Cache $cache |
|
123
|
|
|
* |
|
124
|
1 |
|
* @return ORMException |
|
125
|
|
|
*/ |
|
126
|
1 |
|
public static function metadataCacheUsesNonPersistentCache(CacheDriver $cache) |
|
127
|
|
|
{ |
|
128
|
|
|
return new self('Metadata Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @param string $className |
|
133
|
|
|
* @param string $fieldName |
|
134
|
|
|
* |
|
135
|
|
|
* @return ORMException |
|
136
|
|
|
*/ |
|
137
|
|
|
public static function missingIdentifierField($className, $fieldName) |
|
138
|
|
|
{ |
|
139
|
|
|
return new self("The identifier $fieldName is missing for a query of " . $className); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
5 |
|
/** |
|
143
|
|
|
* @param string $className |
|
144
|
5 |
|
* @param string[] $fieldNames |
|
145
|
|
|
* |
|
146
|
|
|
* @return ORMException |
|
147
|
|
|
*/ |
|
148
|
|
|
public static function unrecognizedIdentifierFields($className, $fieldNames) |
|
149
|
|
|
{ |
|
150
|
|
|
return new self( |
|
151
|
|
|
"Unrecognized identifier fields: '" . implode("', '", $fieldNames) . "' " . |
|
152
|
|
|
"are not present on class '" . $className . "'." |
|
153
|
|
|
); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @return ORMException |
|
158
|
|
|
*/ |
|
159
|
|
|
public static function cantUseInOperatorOnCompositeKeys() |
|
160
|
|
|
{ |
|
161
|
|
|
return new self("Can't use IN operator on entities that have composite keys."); |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|