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