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\Mapping; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* A MappingException indicates that something is wrong with the mapping setup. |
24
|
|
|
* |
25
|
|
|
* @since 2.0 |
26
|
|
|
*/ |
27
|
|
|
class MappingException extends \Doctrine\ORM\ORMException |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @return MappingException |
31
|
|
|
*/ |
32
|
|
|
public static function pathRequired() |
33
|
|
|
{ |
34
|
|
|
return new self("Specifying the paths to your entities is required ". |
35
|
|
|
"in the AnnotationDriver to retrieve all class names."); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param string $entityName |
40
|
|
|
* |
41
|
|
|
* @return MappingException |
42
|
|
|
*/ |
43
|
6 |
View Code Duplication |
public static function identifierRequired($entityName) |
44
|
|
|
{ |
45
|
6 |
|
if (false !== ($parent = get_parent_class($entityName))) { |
46
|
6 |
|
return new self(sprintf( |
47
|
6 |
|
'No identifier/primary key specified for Entity "%s" sub class of "%s". Every Entity must have an identifier/primary key.', |
48
|
6 |
|
$entityName, $parent |
49
|
|
|
)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return new self(sprintf( |
53
|
|
|
'No identifier/primary key specified for Entity "%s". Every Entity must have an identifier/primary key.', |
54
|
|
|
$entityName |
55
|
|
|
)); |
56
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param string $entityName |
61
|
|
|
* @param string $type |
62
|
|
|
* |
63
|
|
|
* @return MappingException |
64
|
|
|
*/ |
65
|
|
|
public static function invalidInheritanceType($entityName, $type) |
66
|
|
|
{ |
67
|
|
|
return new self("The inheritance type '$type' specified for '$entityName' does not exist."); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return MappingException |
72
|
|
|
*/ |
73
|
|
|
public static function generatorNotAllowedWithCompositeId() |
74
|
|
|
{ |
75
|
|
|
return new self("Id generators can't be used with a composite id."); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param string $entity |
80
|
|
|
* |
81
|
|
|
* @return MappingException |
82
|
|
|
*/ |
83
|
1 |
|
public static function missingFieldName($entity) |
84
|
|
|
{ |
85
|
1 |
|
return new self("The field or association mapping misses the 'fieldName' attribute in entity '$entity'."); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param string $fieldName |
90
|
|
|
* |
91
|
|
|
* @return MappingException |
92
|
|
|
*/ |
93
|
|
|
public static function missingTargetEntity($fieldName) |
94
|
|
|
{ |
95
|
|
|
return new self("The association mapping '$fieldName' misses the 'targetEntity' attribute."); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param string $fieldName |
100
|
|
|
* |
101
|
|
|
* @return MappingException |
102
|
|
|
*/ |
103
|
|
|
public static function missingSourceEntity($fieldName) |
104
|
|
|
{ |
105
|
|
|
return new self("The association mapping '$fieldName' misses the 'sourceEntity' attribute."); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param string $fieldName |
110
|
|
|
* |
111
|
|
|
* @return MappingException |
112
|
|
|
*/ |
113
|
1 |
|
public static function missingEmbeddedClass($fieldName) |
114
|
|
|
{ |
115
|
1 |
|
return new self("The embed mapping '$fieldName' misses the 'class' attribute."); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param string $entityName |
120
|
|
|
* @param string $fileName |
121
|
|
|
* |
122
|
|
|
* @return MappingException |
123
|
|
|
*/ |
124
|
|
|
public static function mappingFileNotFound($entityName, $fileName) |
125
|
|
|
{ |
126
|
|
|
return new self("No mapping file found named '$fileName' for class '$entityName'."); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Exception for invalid property name override. |
131
|
|
|
* |
132
|
|
|
* @param string $className The entity's name. |
133
|
|
|
* @param string $fieldName |
134
|
|
|
* |
135
|
|
|
* @return MappingException |
136
|
|
|
*/ |
137
|
2 |
|
public static function invalidOverrideFieldName($className, $fieldName) |
138
|
|
|
{ |
139
|
2 |
|
return new self("Invalid field override named '$fieldName' for class '$className'."); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Exception for invalid property type override. |
144
|
|
|
* |
145
|
|
|
* @param string $className The entity's name. |
146
|
|
|
* @param string $fieldName |
147
|
|
|
* |
148
|
|
|
* @return MappingException |
149
|
|
|
*/ |
150
|
1 |
|
public static function invalidOverrideFieldType($className, $fieldName) |
151
|
|
|
{ |
152
|
1 |
|
return new self("The column type of attribute '$fieldName' on class '$className' could not be changed."); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param string $className |
157
|
|
|
* @param string $fieldName |
158
|
|
|
* |
159
|
|
|
* @return MappingException |
160
|
|
|
*/ |
161
|
1 |
|
public static function mappingNotFound($className, $fieldName) |
162
|
|
|
{ |
163
|
1 |
|
return new self("No mapping found for field '$fieldName' on class '$className'."); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @param string $className |
168
|
|
|
* @param string $queryName |
169
|
|
|
* |
170
|
|
|
* @return MappingException |
171
|
|
|
*/ |
172
|
1 |
|
public static function queryNotFound($className, $queryName) |
173
|
|
|
{ |
174
|
1 |
|
return new self("No query found named '$queryName' on class '$className'."); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param string $className |
179
|
|
|
* @param string $resultName |
180
|
|
|
* |
181
|
|
|
* @return MappingException |
182
|
|
|
*/ |
183
|
|
|
public static function resultMappingNotFound($className, $resultName) |
184
|
|
|
{ |
185
|
|
|
return new self("No result set mapping found named '$resultName' on class '$className'."); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param string $entity |
190
|
|
|
* @param string $queryName |
191
|
|
|
* |
192
|
|
|
* @return MappingException |
193
|
|
|
*/ |
194
|
|
|
public static function emptyQueryMapping($entity, $queryName) |
195
|
|
|
{ |
196
|
|
|
return new self('Query named "'.$queryName.'" in "'.$entity.'" could not be empty.'); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param string $className |
201
|
|
|
* |
202
|
|
|
* @return MappingException |
203
|
|
|
*/ |
204
|
2 |
|
public static function nameIsMandatoryForQueryMapping($className) |
205
|
|
|
{ |
206
|
2 |
|
return new self("Query name on entity class '$className' is not defined."); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param string $entity |
211
|
|
|
* @param string $queryName |
212
|
|
|
* |
213
|
|
|
* @return MappingException |
214
|
|
|
*/ |
215
|
|
|
public static function missingQueryMapping($entity, $queryName) |
216
|
|
|
{ |
217
|
|
|
return new self('Query named "'.$queryName.'" in "'.$entity.' requires a result class or result set mapping.'); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @param string $entity |
222
|
|
|
* @param string $resultName |
223
|
|
|
* |
224
|
|
|
* @return MappingException |
225
|
|
|
*/ |
226
|
1 |
|
public static function missingResultSetMappingEntity($entity, $resultName) |
227
|
|
|
{ |
228
|
1 |
|
return new self('Result set mapping named "'.$resultName.'" in "'.$entity.' requires a entity class name.'); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @param string $entity |
233
|
|
|
* @param string $resultName |
234
|
|
|
* |
235
|
|
|
* @return MappingException |
236
|
|
|
*/ |
237
|
|
|
public static function missingResultSetMappingFieldName($entity, $resultName) |
238
|
|
|
{ |
239
|
|
|
return new self('Result set mapping named "'.$resultName.'" in "'.$entity.' requires a field name.'); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @param string $className |
244
|
|
|
* |
245
|
|
|
* @return MappingException |
246
|
|
|
*/ |
247
|
|
|
public static function nameIsMandatoryForSqlResultSetMapping($className) |
248
|
|
|
{ |
249
|
|
|
return new self("Result set mapping name on entity class '$className' is not defined."); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @param string $fieldName |
254
|
|
|
* |
255
|
|
|
* @return MappingException |
256
|
|
|
*/ |
257
|
|
|
public static function oneToManyRequiresMappedBy($fieldName) |
258
|
|
|
{ |
259
|
|
|
return new self("OneToMany mapping on field '$fieldName' requires the 'mappedBy' attribute."); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @param string $fieldName |
264
|
|
|
* |
265
|
|
|
* @return MappingException |
266
|
|
|
*/ |
267
|
|
|
public static function joinTableRequired($fieldName) |
268
|
|
|
{ |
269
|
|
|
return new self("The mapping of field '$fieldName' requires an the 'joinTable' attribute."); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Called if a required option was not found but is required |
274
|
|
|
* |
275
|
|
|
* @param string $field Which field cannot be processed? |
276
|
|
|
* @param string $expectedOption Which option is required |
277
|
|
|
* @param string $hint Can optionally be used to supply a tip for common mistakes, |
278
|
|
|
* e.g. "Did you think of the plural s?" |
279
|
|
|
* |
280
|
|
|
* @return MappingException |
281
|
|
|
*/ |
282
|
|
|
static function missingRequiredOption($field, $expectedOption, $hint = '') |
|
|
|
|
283
|
|
|
{ |
284
|
|
|
$message = "The mapping of field '{$field}' is invalid: The option '{$expectedOption}' is required."; |
285
|
|
|
|
286
|
|
|
if ( ! empty($hint)) { |
287
|
|
|
$message .= ' (Hint: ' . $hint . ')'; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
return new self($message); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* Generic exception for invalid mappings. |
295
|
|
|
* |
296
|
|
|
* @param string $fieldName |
297
|
|
|
* |
298
|
|
|
* @return MappingException |
299
|
|
|
*/ |
300
|
|
|
public static function invalidMapping($fieldName) |
301
|
|
|
{ |
302
|
|
|
return new self("The mapping of field '$fieldName' is invalid."); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Exception for reflection exceptions - adds the entity name, |
307
|
|
|
* because there might be long classnames that will be shortened |
308
|
|
|
* within the stacktrace |
309
|
|
|
* |
310
|
|
|
* @param string $entity The entity's name |
311
|
|
|
* @param \ReflectionException $previousException |
312
|
|
|
* |
313
|
|
|
* @return MappingException |
314
|
|
|
*/ |
315
|
|
|
public static function reflectionFailure($entity, \ReflectionException $previousException) |
316
|
|
|
{ |
317
|
|
|
return new self('An error occurred in ' . $entity, 0, $previousException); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* @param string $className |
322
|
|
|
* @param string $joinColumn |
323
|
|
|
* |
324
|
|
|
* @return MappingException |
325
|
|
|
*/ |
326
|
|
|
public static function joinColumnMustPointToMappedField($className, $joinColumn) |
327
|
|
|
{ |
328
|
|
|
return new self('The column ' . $joinColumn . ' must be mapped to a field in class ' |
329
|
|
|
. $className . ' since it is referenced by a join column of another class.'); |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
/** |
333
|
|
|
* @param string $className |
334
|
|
|
* |
335
|
|
|
* @return MappingException |
336
|
|
|
*/ |
337
|
5 |
View Code Duplication |
public static function classIsNotAValidEntityOrMappedSuperClass($className) |
338
|
|
|
{ |
339
|
5 |
|
if (false !== ($parent = get_parent_class($className))) { |
340
|
3 |
|
return new self(sprintf( |
341
|
3 |
|
'Class "%s" sub class of "%s" is not a valid entity or mapped super class.', |
342
|
3 |
|
$className, $parent |
343
|
|
|
)); |
344
|
|
|
} |
345
|
|
|
|
346
|
2 |
|
return new self(sprintf( |
347
|
2 |
|
'Class "%s" is not a valid entity or mapped super class.', |
348
|
2 |
|
$className |
349
|
|
|
)); |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* @param string $className |
354
|
|
|
* @param string $propertyName |
355
|
|
|
* |
356
|
|
|
* @return MappingException |
357
|
|
|
*/ |
358
|
|
|
public static function propertyTypeIsRequired($className, $propertyName) |
359
|
|
|
{ |
360
|
|
|
return new self("The attribute 'type' is required for the column description of property ".$className."::\$".$propertyName."."); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* @param string $className |
365
|
|
|
* |
366
|
|
|
* @return MappingException |
367
|
|
|
*/ |
368
|
|
|
public static function tableIdGeneratorNotImplemented($className) |
369
|
|
|
{ |
370
|
|
|
return new self("TableIdGenerator is not yet implemented for use with class ".$className); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* @param string $entity The entity's name. |
375
|
|
|
* @param string $fieldName The name of the field that was already declared. |
376
|
|
|
* |
377
|
|
|
* @return MappingException |
378
|
|
|
*/ |
379
|
2 |
|
public static function duplicateFieldMapping($entity, $fieldName) |
380
|
|
|
{ |
381
|
2 |
|
return new self('Property "'.$fieldName.'" in "'.$entity.'" was already declared, but it must be declared only once'); |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* @param string $entity |
386
|
|
|
* @param string $fieldName |
387
|
|
|
* |
388
|
|
|
* @return MappingException |
389
|
|
|
*/ |
390
|
1 |
|
public static function duplicateAssociationMapping($entity, $fieldName) |
391
|
|
|
{ |
392
|
1 |
|
return new self('Property "'.$fieldName.'" in "'.$entity.'" was already declared, but it must be declared only once'); |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* @param string $entity |
397
|
|
|
* @param string $queryName |
398
|
|
|
* |
399
|
|
|
* @return MappingException |
400
|
|
|
*/ |
401
|
2 |
|
public static function duplicateQueryMapping($entity, $queryName) |
402
|
|
|
{ |
403
|
2 |
|
return new self('Query named "'.$queryName.'" in "'.$entity.'" was already declared, but it must be declared only once'); |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* @param string $entity |
408
|
|
|
* @param string $resultName |
409
|
|
|
* |
410
|
|
|
* @return MappingException |
411
|
|
|
*/ |
412
|
1 |
|
public static function duplicateResultSetMapping($entity, $resultName) |
413
|
|
|
{ |
414
|
1 |
|
return new self('Result set mapping named "'.$resultName.'" in "'.$entity.'" was already declared, but it must be declared only once'); |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* @param string $entity |
419
|
|
|
* |
420
|
|
|
* @return MappingException |
421
|
|
|
*/ |
422
|
1 |
|
public static function singleIdNotAllowedOnCompositePrimaryKey($entity) |
423
|
|
|
{ |
424
|
1 |
|
return new self('Single id is not allowed on composite primary key in entity '.$entity); |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* @param string $entity |
429
|
|
|
* |
430
|
|
|
* @return MappingException |
431
|
|
|
*/ |
432
|
1 |
|
public static function noIdDefined($entity) |
433
|
|
|
{ |
434
|
1 |
|
return new self('No ID defined for entity ' . $entity); |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* @param string $entity |
439
|
|
|
* @param string $fieldName |
440
|
|
|
* @param string $unsupportedType |
441
|
|
|
* |
442
|
|
|
* @return MappingException |
443
|
|
|
*/ |
444
|
1 |
|
public static function unsupportedOptimisticLockingType($entity, $fieldName, $unsupportedType) |
445
|
|
|
{ |
446
|
1 |
|
return new self('Locking type "'.$unsupportedType.'" (specified in "'.$entity.'", field "'.$fieldName.'") ' |
447
|
1 |
|
.'is not supported by Doctrine.' |
448
|
|
|
); |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* @param string|null $path |
453
|
|
|
* |
454
|
|
|
* @return MappingException |
455
|
|
|
*/ |
456
|
|
|
public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null) |
457
|
|
|
{ |
458
|
|
|
if ( ! empty($path)) { |
459
|
|
|
$path = '[' . $path . ']'; |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
return new self( |
463
|
|
|
'File mapping drivers must have a valid directory path, ' . |
464
|
|
|
'however the given path ' . $path . ' seems to be incorrect!' |
465
|
|
|
); |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
/** |
469
|
|
|
* Returns an exception that indicates that a class used in a discriminator map does not exist. |
470
|
|
|
* An example would be an outdated (maybe renamed) classname. |
471
|
|
|
* |
472
|
|
|
* @param string $className The class that could not be found |
473
|
|
|
* @param string $owningClass The class that declares the discriminator map. |
474
|
|
|
* |
475
|
|
|
* @return MappingException |
476
|
|
|
*/ |
477
|
|
|
public static function invalidClassInDiscriminatorMap($className, $owningClass) |
478
|
|
|
{ |
479
|
|
|
return new self( |
480
|
|
|
"Entity class '$className' used in the discriminator map of class '$owningClass' ". |
481
|
|
|
"does not exist." |
482
|
|
|
); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* @param string $className |
487
|
|
|
* @param array $entries |
488
|
|
|
* @param array $map |
489
|
|
|
* |
490
|
|
|
* @return MappingException |
491
|
|
|
*/ |
492
|
|
|
public static function duplicateDiscriminatorEntry($className, array $entries, array $map) |
493
|
|
|
{ |
494
|
|
|
return new self( |
495
|
|
|
"The entries " . implode(', ', $entries) . " in discriminator map of class '" . $className . "' is duplicated. " . |
496
|
|
|
"If the discriminator map is automatically generated you have to convert it to an explicit discriminator map now. " . |
497
|
|
|
"The entries of the current map are: @DiscriminatorMap({" . implode(', ', array_map( |
498
|
|
|
function($a, $b) { return "'$a': '$b'"; }, array_keys($map), array_values($map) |
499
|
|
|
)) . "})" |
500
|
|
|
); |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* @param string $className |
505
|
|
|
* |
506
|
|
|
* @return MappingException |
507
|
|
|
*/ |
508
|
|
|
public static function missingDiscriminatorMap($className) |
509
|
|
|
{ |
510
|
|
|
return new self("Entity class '$className' is using inheritance but no discriminator map was defined."); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
/** |
514
|
|
|
* @param string $className |
515
|
|
|
* |
516
|
|
|
* @return MappingException |
517
|
|
|
*/ |
518
|
|
|
public static function missingDiscriminatorColumn($className) |
519
|
|
|
{ |
520
|
|
|
return new self("Entity class '$className' is using inheritance but no discriminator column was defined."); |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
/** |
524
|
|
|
* @param string $className |
525
|
|
|
* @param string $type |
526
|
|
|
* |
527
|
|
|
* @return MappingException |
528
|
|
|
*/ |
529
|
|
|
public static function invalidDiscriminatorColumnType($className, $type) |
530
|
|
|
{ |
531
|
|
|
return new self("Discriminator column type on entity class '$className' is not allowed to be '$type'. 'string' or 'integer' type variables are suggested!"); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* @param string $className |
536
|
|
|
* |
537
|
|
|
* @return MappingException |
538
|
|
|
*/ |
539
|
1 |
|
public static function nameIsMandatoryForDiscriminatorColumns($className) |
540
|
|
|
{ |
541
|
1 |
|
return new self("Discriminator column name on entity class '$className' is not defined."); |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* @param string $className |
546
|
|
|
* @param string $fieldName |
547
|
|
|
* |
548
|
|
|
* @return MappingException |
549
|
|
|
*/ |
550
|
|
|
public static function cannotVersionIdField($className, $fieldName) |
551
|
|
|
{ |
552
|
|
|
return new self("Setting Id field '$fieldName' as versionable in entity class '$className' is not supported."); |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* @param string $className |
557
|
|
|
* @param string $fieldName |
558
|
|
|
* @param string $type |
559
|
|
|
* |
560
|
|
|
* @return MappingException |
561
|
|
|
*/ |
562
|
|
|
public static function sqlConversionNotAllowedForIdentifiers($className, $fieldName, $type) |
563
|
|
|
{ |
564
|
|
|
return new self("It is not possible to set id field '$fieldName' to type '$type' in entity class '$className'. The type '$type' requires conversion SQL which is not allowed for identifiers."); |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
/** |
568
|
|
|
* @param string $className |
569
|
|
|
* @param string $columnName |
570
|
|
|
* |
571
|
|
|
* @return MappingException |
572
|
|
|
*/ |
573
|
3 |
|
public static function duplicateColumnName($className, $columnName) |
574
|
|
|
{ |
575
|
3 |
|
return new self("Duplicate definition of column '".$columnName."' on entity '".$className."' in a field or discriminator column mapping."); |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
/** |
579
|
|
|
* @param string $className |
580
|
|
|
* @param string $field |
581
|
|
|
* |
582
|
|
|
* @return MappingException |
583
|
|
|
*/ |
584
|
1 |
|
public static function illegalToManyAssociationOnMappedSuperclass($className, $field) |
585
|
|
|
{ |
586
|
1 |
|
return new self("It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass '".$className."#".$field."'."); |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
/** |
590
|
|
|
* @param string $className |
591
|
|
|
* @param string $targetEntity |
592
|
|
|
* @param string $targetField |
593
|
|
|
* |
594
|
|
|
* @return MappingException |
595
|
|
|
*/ |
596
|
|
|
public static function cannotMapCompositePrimaryKeyEntitiesAsForeignId($className, $targetEntity, $targetField) |
597
|
|
|
{ |
598
|
|
|
return new self("It is not possible to map entity '".$className."' with a composite primary key ". |
599
|
|
|
"as part of the primary key of another entity '".$targetEntity."#".$targetField."'."); |
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
/** |
603
|
|
|
* @param string $className |
604
|
|
|
* @param string $field |
605
|
|
|
* |
606
|
|
|
* @return MappingException |
607
|
|
|
*/ |
608
|
|
|
public static function noSingleAssociationJoinColumnFound($className, $field) |
609
|
|
|
{ |
610
|
|
|
return new self("'$className#$field' is not an association with a single join column."); |
611
|
|
|
} |
612
|
|
|
|
613
|
|
|
/** |
614
|
|
|
* @param string $className |
615
|
|
|
* @param string $column |
616
|
|
|
* |
617
|
|
|
* @return MappingException |
618
|
|
|
*/ |
619
|
|
|
public static function noFieldNameFoundForColumn($className, $column) |
620
|
|
|
{ |
621
|
|
|
return new self("Cannot find a field on '$className' that is mapped to column '$column'. Either the ". |
622
|
|
|
"field does not exist or an association exists but it has multiple join columns."); |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
/** |
626
|
|
|
* @param string $className |
627
|
|
|
* @param string $field |
628
|
|
|
* |
629
|
|
|
* @return MappingException |
630
|
|
|
*/ |
631
|
1 |
|
public static function illegalOrphanRemovalOnIdentifierAssociation($className, $field) |
632
|
|
|
{ |
633
|
1 |
|
return new self("The orphan removal option is not allowed on an association that is ". |
634
|
1 |
|
"part of the identifier in '$className#$field'."); |
635
|
|
|
} |
636
|
|
|
|
637
|
|
|
/** |
638
|
|
|
* @param string $className |
639
|
|
|
* @param string $field |
640
|
|
|
* |
641
|
|
|
* @return MappingException |
642
|
|
|
*/ |
643
|
1 |
|
public static function illegalOrphanRemoval($className, $field) |
644
|
|
|
{ |
645
|
1 |
|
return new self("Orphan removal is only allowed on one-to-one and one-to-many ". |
646
|
1 |
|
"associations, but " . $className."#" .$field . " is not."); |
647
|
|
|
} |
648
|
|
|
|
649
|
|
|
/** |
650
|
|
|
* @param string $className |
651
|
|
|
* @param string $field |
652
|
|
|
* |
653
|
|
|
* @return MappingException |
654
|
|
|
*/ |
655
|
2 |
|
public static function illegalInverseIdentifierAssociation($className, $field) |
656
|
|
|
{ |
657
|
2 |
|
return new self("An inverse association is not allowed to be identifier in '$className#$field'."); |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* @param string $className |
662
|
|
|
* @param string $field |
663
|
|
|
* |
664
|
|
|
* @return MappingException |
665
|
|
|
*/ |
666
|
3 |
|
public static function illegalToManyIdentifierAssociation($className, $field) |
667
|
|
|
{ |
668
|
3 |
|
return new self("Many-to-many or one-to-many associations are not allowed to be identifier in '$className#$field'."); |
669
|
|
|
} |
670
|
|
|
|
671
|
|
|
/** |
672
|
|
|
* @param string $className |
673
|
|
|
* |
674
|
|
|
* @return MappingException |
675
|
|
|
*/ |
676
|
1 |
|
public static function noInheritanceOnMappedSuperClass($className) |
677
|
|
|
{ |
678
|
1 |
|
return new self("It is not supported to define inheritance information on a mapped superclass '" . $className . "'."); |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
/** |
682
|
|
|
* @param string $className |
683
|
|
|
* @param string $rootClassName |
684
|
|
|
* |
685
|
|
|
* @return MappingException |
686
|
|
|
*/ |
687
|
1 |
|
public static function mappedClassNotPartOfDiscriminatorMap($className, $rootClassName) |
688
|
|
|
{ |
689
|
1 |
|
return new self( |
690
|
1 |
|
"Entity '" . $className . "' has to be part of the discriminator map of '" . $rootClassName . "' " . |
691
|
1 |
|
"to be properly mapped in the inheritance hierarchy. Alternatively you can make '".$className."' an abstract class " . |
692
|
1 |
|
"to avoid this exception from occurring." |
693
|
|
|
); |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* @param string $className |
698
|
|
|
* @param string $methodName |
699
|
|
|
* |
700
|
|
|
* @return MappingException |
701
|
|
|
*/ |
702
|
1 |
|
public static function lifecycleCallbackMethodNotFound($className, $methodName) |
703
|
|
|
{ |
704
|
1 |
|
return new self("Entity '" . $className . "' has no method '" . $methodName . "' to be registered as lifecycle callback."); |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
/** |
708
|
|
|
* @param string $listenerName |
709
|
|
|
* @param string $className |
710
|
|
|
* |
711
|
|
|
* @return \Doctrine\ORM\Mapping\MappingException |
712
|
|
|
*/ |
713
|
1 |
|
public static function entityListenerClassNotFound($listenerName, $className) |
714
|
|
|
{ |
715
|
1 |
|
return new self(sprintf('Entity Listener "%s" declared on "%s" not found.', $listenerName, $className)); |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
/** |
719
|
|
|
* @param string $listenerName |
720
|
|
|
* @param string $methodName |
721
|
|
|
* @param string $className |
722
|
|
|
* |
723
|
|
|
* @return \Doctrine\ORM\Mapping\MappingException |
724
|
|
|
*/ |
725
|
1 |
|
public static function entityListenerMethodNotFound($listenerName, $methodName, $className) |
726
|
|
|
{ |
727
|
1 |
|
return new self(sprintf('Entity Listener "%s" declared on "%s" has no method "%s".', $listenerName, $className, $methodName)); |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
/** |
731
|
|
|
* @param string $listenerName |
732
|
|
|
* @param string $methodName |
733
|
|
|
* @param string $className |
734
|
|
|
* |
735
|
|
|
* @return \Doctrine\ORM\Mapping\MappingException |
736
|
|
|
*/ |
737
|
1 |
|
public static function duplicateEntityListener($listenerName, $methodName, $className) |
738
|
|
|
{ |
739
|
1 |
|
return new self(sprintf('Entity Listener "%s#%s()" in "%s" was already declared, but it must be declared only once.', $listenerName, $methodName, $className)); |
740
|
|
|
} |
741
|
|
|
|
742
|
|
|
/** |
743
|
|
|
* @param string $className |
744
|
|
|
* @param string $annotation |
745
|
|
|
* |
746
|
|
|
* @return MappingException |
747
|
|
|
*/ |
748
|
|
|
public static function invalidFetchMode($className, $annotation) |
749
|
|
|
{ |
750
|
|
|
return new self("Entity '" . $className . "' has a mapping with invalid fetch mode '" . $annotation . "'"); |
751
|
|
|
} |
752
|
|
|
|
753
|
|
|
/** |
754
|
|
|
* @param string $className |
755
|
|
|
* |
756
|
|
|
* @return MappingException |
757
|
|
|
*/ |
758
|
|
|
public static function compositeKeyAssignedIdGeneratorRequired($className) |
759
|
|
|
{ |
760
|
|
|
return new self("Entity '". $className . "' has a composite identifier but uses an ID generator other than manually assigning (Identity, Sequence). This is not supported."); |
761
|
|
|
} |
762
|
|
|
|
763
|
|
|
/** |
764
|
|
|
* @param string $targetEntity |
765
|
|
|
* @param string $sourceEntity |
766
|
|
|
* @param string $associationName |
767
|
|
|
* |
768
|
|
|
* @return MappingException |
769
|
|
|
*/ |
770
|
1 |
|
public static function invalidTargetEntityClass($targetEntity, $sourceEntity, $associationName) |
771
|
|
|
{ |
772
|
1 |
|
return new self("The target-entity " . $targetEntity . " cannot be found in '" . $sourceEntity."#".$associationName."'."); |
773
|
|
|
} |
774
|
|
|
|
775
|
|
|
/** |
776
|
|
|
* @param array $cascades |
777
|
|
|
* @param string $className |
778
|
|
|
* @param string $propertyName |
779
|
|
|
* |
780
|
|
|
* @return MappingException |
781
|
|
|
*/ |
782
|
|
|
public static function invalidCascadeOption(array $cascades, $className, $propertyName) |
783
|
|
|
{ |
784
|
|
|
$cascades = implode(", ", array_map(function ($e) { return "'" . $e . "'"; }, $cascades)); |
785
|
|
|
|
786
|
1 |
|
return new self(sprintf( |
787
|
1 |
|
"You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'", |
788
|
1 |
|
$className, |
789
|
1 |
|
$propertyName, |
790
|
1 |
|
$cascades |
791
|
|
|
)); |
792
|
|
|
} |
793
|
|
|
|
794
|
|
|
/** |
795
|
|
|
* @param string $className |
796
|
|
|
* |
797
|
|
|
* @return MappingException |
798
|
|
|
*/ |
799
|
1 |
|
public static function missingSequenceName($className) |
800
|
|
|
{ |
801
|
1 |
|
return new self( |
802
|
1 |
|
sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className) |
803
|
|
|
); |
804
|
|
|
} |
805
|
|
|
|
806
|
|
|
/** |
807
|
|
|
* @param string $className |
808
|
|
|
* @param string $propertyName |
809
|
|
|
* |
810
|
|
|
* @return MappingException |
811
|
|
|
*/ |
812
|
2 |
|
public static function infiniteEmbeddableNesting($className, $propertyName) |
813
|
|
|
{ |
814
|
2 |
|
return new self( |
815
|
2 |
|
sprintf( |
816
|
|
|
'Infinite nesting detected for embedded property %s::%s. ' . |
817
|
2 |
|
'You cannot embed an embeddable from the same type inside an embeddable.', |
818
|
2 |
|
$className, |
819
|
2 |
|
$propertyName |
820
|
|
|
) |
821
|
|
|
); |
822
|
|
|
} |
823
|
|
|
} |
824
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.