231
231
*/
232
232
public const DEFAULT_DISCRIMINATOR_FIELD = '_doctrine_class_name ' ;
233
233
234
+ /**
235
+ * Association types
236
+ */
234
237
public const REFERENCE_ONE = 1 ;
235
238
public const REFERENCE_MANY = 2 ;
236
239
public const EMBED_ONE = 3 ;
237
240
public const EMBED_MANY = 4 ;
238
- public const MANY = 'many ' ;
239
- public const ONE = 'one ' ;
241
+
242
+ /**
243
+ * Mapping types
244
+ */
245
+ public const MANY = 'many ' ;
246
+ public const ONE = 'one ' ;
240
247
241
248
/**
242
249
* The types of storeAs references
@@ -1136,7 +1143,7 @@ public function setShardKey(array $keys, array $options = []): void
1136
1143
continue ;
1137
1144
}
1138
1145
1139
- if (in_array ($ this ->fieldMappings [$ field ]['type ' ], [' many ' , ' collection ' ])) {
1146
+ if (in_array ($ this ->fieldMappings [$ field ]['type ' ], [self :: MANY , Type:: COLLECTION ])) {
1140
1147
throw MappingException::noMultiKeyShardKeys ($ this ->getName (), $ field );
1141
1148
}
1142
1149
@@ -1456,7 +1463,7 @@ private function applyStorageStrategy(array &$mapping): void
1456
1463
}
1457
1464
1458
1465
switch (true ) {
1459
- case $ mapping ['type ' ] === ' many ' :
1466
+ case $ mapping ['type ' ] === self :: MANY :
1460
1467
$ defaultStrategy = CollectionHelper::DEFAULT_STRATEGY ;
1461
1468
$ allowedStrategies = [
1462
1469
self ::STORAGE_STRATEGY_PUSH_ALL ,
@@ -1468,7 +1475,7 @@ private function applyStorageStrategy(array &$mapping): void
1468
1475
];
1469
1476
break ;
1470
1477
1471
- case $ mapping ['type ' ] === ' one ' :
1478
+ case $ mapping ['type ' ] === self :: ONE :
1472
1479
$ defaultStrategy = self ::STORAGE_STRATEGY_SET ;
1473
1480
$ allowedStrategies = [self ::STORAGE_STRATEGY_SET ];
1474
1481
break ;
@@ -1491,7 +1498,7 @@ private function applyStorageStrategy(array &$mapping): void
1491
1498
}
1492
1499
1493
1500
if (
1494
- isset ($ mapping ['reference ' ]) && $ mapping ['type ' ] === ' many ' && $ mapping ['isOwningSide ' ]
1501
+ isset ($ mapping ['reference ' ]) && $ mapping ['type ' ] === self :: MANY && $ mapping ['isOwningSide ' ]
1495
1502
&& ! empty ($ mapping ['sort ' ]) && ! CollectionHelper::usesSet ($ mapping ['strategy ' ])
1496
1503
) {
1497
1504
throw MappingException::referenceManySortMustNotBeUsedWithNonSetCollectionStrategy ($ this ->name , $ mapping ['fieldName ' ], $ mapping ['strategy ' ]);
@@ -1506,7 +1513,7 @@ private function applyStorageStrategy(array &$mapping): void
1506
1513
public function mapOneEmbedded (array $ mapping ): void
1507
1514
{
1508
1515
$ mapping ['embedded ' ] = true ;
1509
- $ mapping ['type ' ] = ' one ' ;
1516
+ $ mapping ['type ' ] = self :: ONE ;
1510
1517
$ this ->mapField ($ mapping );
1511
1518
}
1512
1519
@@ -1518,7 +1525,7 @@ public function mapOneEmbedded(array $mapping): void
1518
1525
public function mapManyEmbedded (array $ mapping ): void
1519
1526
{
1520
1527
$ mapping ['embedded ' ] = true ;
1521
- $ mapping ['type ' ] = ' many ' ;
1528
+ $ mapping ['type ' ] = self :: MANY ;
1522
1529
$ this ->mapField ($ mapping );
1523
1530
}
1524
1531
@@ -1530,7 +1537,7 @@ public function mapManyEmbedded(array $mapping): void
1530
1537
public function mapOneReference (array $ mapping ): void
1531
1538
{
1532
1539
$ mapping ['reference ' ] = true ;
1533
- $ mapping ['type ' ] = ' one ' ;
1540
+ $ mapping ['type ' ] = self :: ONE ;
1534
1541
$ this ->mapField ($ mapping );
1535
1542
}
1536
1543
@@ -1542,7 +1549,7 @@ public function mapOneReference(array $mapping): void
1542
1549
public function mapManyReference (array $ mapping ): void
1543
1550
{
1544
1551
$ mapping ['reference ' ] = true ;
1545
- $ mapping ['type ' ] = ' many ' ;
1552
+ $ mapping ['type ' ] = self :: MANY ;
1546
1553
$ this ->mapField ($ mapping );
1547
1554
}
1548
1555
@@ -2223,7 +2230,7 @@ public function mapField(array $mapping): array
2223
2230
throw MappingException::owningAndInverseReferencesRequireTargetDocument ($ this ->name , $ mapping ['fieldName ' ]);
2224
2231
}
2225
2232
2226
- if ($ this ->isEmbeddedDocument && $ mapping ['type ' ] === ' many ' && isset ($ mapping ['strategy ' ]) && CollectionHelper::isAtomic ($ mapping ['strategy ' ])) {
2233
+ if ($ this ->isEmbeddedDocument && $ mapping ['type ' ] === self :: MANY && isset ($ mapping ['strategy ' ]) && CollectionHelper::isAtomic ($ mapping ['strategy ' ])) {
2227
2234
throw MappingException::atomicCollectionStrategyNotAllowed ($ mapping ['strategy ' ], $ this ->name , $ mapping ['fieldName ' ]);
2228
2235
}
2229
2236
@@ -2241,19 +2248,19 @@ public function mapField(array $mapping): array
2241
2248
);
2242
2249
}
2243
2250
2244
- if (isset ($ mapping ['reference ' ]) && $ mapping ['type ' ] === ' one ' ) {
2251
+ if (isset ($ mapping ['reference ' ]) && $ mapping ['type ' ] === self :: ONE ) {
2245
2252
$ mapping ['association ' ] = self ::REFERENCE_ONE ;
2246
2253
}
2247
2254
2248
- if (isset ($ mapping ['reference ' ]) && $ mapping ['type ' ] === ' many ' ) {
2255
+ if (isset ($ mapping ['reference ' ]) && $ mapping ['type ' ] === self :: MANY ) {
2249
2256
$ mapping ['association ' ] = self ::REFERENCE_MANY ;
2250
2257
}
2251
2258
2252
- if (isset ($ mapping ['embedded ' ]) && $ mapping ['type ' ] === ' one ' ) {
2259
+ if (isset ($ mapping ['embedded ' ]) && $ mapping ['type ' ] === self :: ONE ) {
2253
2260
$ mapping ['association ' ] = self ::EMBED_ONE ;
2254
2261
}
2255
2262
2256
- if (isset ($ mapping ['embedded ' ]) && $ mapping ['type ' ] === ' many ' ) {
2263
+ if (isset ($ mapping ['embedded ' ]) && $ mapping ['type ' ] === self :: MANY ) {
2257
2264
$ mapping ['association ' ] = self ::EMBED_MANY ;
2258
2265
}
2259
2266
0 commit comments