diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Mapping/Builder/ManyToManyAssociationBuilder.php')
-rw-r--r-- | vendor/doctrine/orm/src/Mapping/Builder/ManyToManyAssociationBuilder.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Mapping/Builder/ManyToManyAssociationBuilder.php b/vendor/doctrine/orm/src/Mapping/Builder/ManyToManyAssociationBuilder.php new file mode 100644 index 0000000..b83a8ba --- /dev/null +++ b/vendor/doctrine/orm/src/Mapping/Builder/ManyToManyAssociationBuilder.php | |||
@@ -0,0 +1,73 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Mapping\Builder; | ||
6 | |||
7 | /** | ||
8 | * ManyToMany Association Builder | ||
9 | * | ||
10 | * @link www.doctrine-project.com | ||
11 | */ | ||
12 | class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder | ||
13 | { | ||
14 | private string|null $joinTableName = null; | ||
15 | |||
16 | /** @var mixed[] */ | ||
17 | private array $inverseJoinColumns = []; | ||
18 | |||
19 | /** @return $this */ | ||
20 | public function setJoinTable(string $name): static | ||
21 | { | ||
22 | $this->joinTableName = $name; | ||
23 | |||
24 | return $this; | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * Adds Inverse Join Columns. | ||
29 | * | ||
30 | * @return $this | ||
31 | */ | ||
32 | public function addInverseJoinColumn( | ||
33 | string $columnName, | ||
34 | string $referencedColumnName, | ||
35 | bool $nullable = true, | ||
36 | bool $unique = false, | ||
37 | string|null $onDelete = null, | ||
38 | string|null $columnDef = null, | ||
39 | ): static { | ||
40 | $this->inverseJoinColumns[] = [ | ||
41 | 'name' => $columnName, | ||
42 | 'referencedColumnName' => $referencedColumnName, | ||
43 | 'nullable' => $nullable, | ||
44 | 'unique' => $unique, | ||
45 | 'onDelete' => $onDelete, | ||
46 | 'columnDefinition' => $columnDef, | ||
47 | ]; | ||
48 | |||
49 | return $this; | ||
50 | } | ||
51 | |||
52 | public function build(): ClassMetadataBuilder | ||
53 | { | ||
54 | $mapping = $this->mapping; | ||
55 | $mapping['joinTable'] = []; | ||
56 | if ($this->joinColumns) { | ||
57 | $mapping['joinTable']['joinColumns'] = $this->joinColumns; | ||
58 | } | ||
59 | |||
60 | if ($this->inverseJoinColumns) { | ||
61 | $mapping['joinTable']['inverseJoinColumns'] = $this->inverseJoinColumns; | ||
62 | } | ||
63 | |||
64 | if ($this->joinTableName) { | ||
65 | $mapping['joinTable']['name'] = $this->joinTableName; | ||
66 | } | ||
67 | |||
68 | $cm = $this->builder->getClassMetadata(); | ||
69 | $cm->mapManyToMany($mapping); | ||
70 | |||
71 | return $this->builder; | ||
72 | } | ||
73 | } | ||