diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Mapping/OneToManyAssociationMapping.php')
-rw-r--r-- | vendor/doctrine/orm/src/Mapping/OneToManyAssociationMapping.php | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Mapping/OneToManyAssociationMapping.php b/vendor/doctrine/orm/src/Mapping/OneToManyAssociationMapping.php new file mode 100644 index 0000000..786e981 --- /dev/null +++ b/vendor/doctrine/orm/src/Mapping/OneToManyAssociationMapping.php | |||
@@ -0,0 +1,75 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Mapping; | ||
6 | |||
7 | final class OneToManyAssociationMapping extends ToManyInverseSideMapping | ||
8 | { | ||
9 | /** | ||
10 | * @param mixed[] $mappingArray | ||
11 | * @psalm-param array{ | ||
12 | * fieldName: string, | ||
13 | * sourceEntity: class-string, | ||
14 | * targetEntity: class-string, | ||
15 | * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, | ||
16 | * fetch?: ClassMetadata::FETCH_*|null, | ||
17 | * inherited?: class-string|null, | ||
18 | * declared?: class-string|null, | ||
19 | * cache?: array<mixed>|null, | ||
20 | * id?: bool|null, | ||
21 | * isOnDeleteCascade?: bool|null, | ||
22 | * originalClass?: class-string|null, | ||
23 | * originalField?: string|null, | ||
24 | * orphanRemoval?: bool, | ||
25 | * unique?: bool|null, | ||
26 | * joinTable?: mixed[]|null, | ||
27 | * type?: int, | ||
28 | * isOwningSide: bool, | ||
29 | * } $mappingArray | ||
30 | */ | ||
31 | public static function fromMappingArray(array $mappingArray): static | ||
32 | { | ||
33 | $mapping = parent::fromMappingArray($mappingArray); | ||
34 | |||
35 | if ($mapping->orphanRemoval && ! $mapping->isCascadeRemove()) { | ||
36 | $mapping->cascade[] = 'remove'; | ||
37 | } | ||
38 | |||
39 | return $mapping; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * @param mixed[] $mappingArray | ||
44 | * @psalm-param array{ | ||
45 | * fieldName: string, | ||
46 | * sourceEntity: class-string, | ||
47 | * targetEntity: class-string, | ||
48 | * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, | ||
49 | * fetch?: ClassMetadata::FETCH_*|null, | ||
50 | * inherited?: class-string|null, | ||
51 | * declared?: class-string|null, | ||
52 | * cache?: array<mixed>|null, | ||
53 | * id?: bool|null, | ||
54 | * isOnDeleteCascade?: bool|null, | ||
55 | * originalClass?: class-string|null, | ||
56 | * originalField?: string|null, | ||
57 | * orphanRemoval?: bool, | ||
58 | * unique?: bool|null, | ||
59 | * joinTable?: mixed[]|null, | ||
60 | * type?: int, | ||
61 | * isOwningSide: bool, | ||
62 | * } $mappingArray | ||
63 | */ | ||
64 | public static function fromMappingArrayAndName(array $mappingArray, string $name): static | ||
65 | { | ||
66 | $mapping = self::fromMappingArray($mappingArray); | ||
67 | |||
68 | // OneToMany-side MUST be inverse (must have mappedBy) | ||
69 | if (! isset($mapping->mappedBy)) { | ||
70 | throw MappingException::oneToManyRequiresMappedBy($name, $mapping->fieldName); | ||
71 | } | ||
72 | |||
73 | return $mapping; | ||
74 | } | ||
75 | } | ||