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