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