mailpoet
/
vendor-prefixed
/
doctrine
/
orm
/
src
/
Mapping
/
Builder
/
ManyToManyAssociationBuilder.php
AssociationBuilder.php
9 months ago
ClassMetadataBuilder.php
9 months ago
EmbeddedBuilder.php
9 months ago
EntityListenerBuilder.php
9 months ago
FieldBuilder.php
9 months ago
ManyToManyAssociationBuilder.php
9 months ago
OneToManyAssociationBuilder.php
9 months ago
index.php
9 months ago
ManyToManyAssociationBuilder.php
37 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\ORM\Mapping\Builder; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder |
| 6 | { |
| 7 | private $joinTableName; |
| 8 | private $inverseJoinColumns = []; |
| 9 | public function setJoinTable($name) |
| 10 | { |
| 11 | $this->joinTableName = $name; |
| 12 | return $this; |
| 13 | } |
| 14 | public function addInverseJoinColumn($columnName, $referencedColumnName, $nullable = \true, $unique = \false, $onDelete = null, $columnDef = null) |
| 15 | { |
| 16 | $this->inverseJoinColumns[] = ['name' => $columnName, 'referencedColumnName' => $referencedColumnName, 'nullable' => $nullable, 'unique' => $unique, 'onDelete' => $onDelete, 'columnDefinition' => $columnDef]; |
| 17 | return $this; |
| 18 | } |
| 19 | public function build() |
| 20 | { |
| 21 | $mapping = $this->mapping; |
| 22 | $mapping['joinTable'] = []; |
| 23 | if ($this->joinColumns) { |
| 24 | $mapping['joinTable']['joinColumns'] = $this->joinColumns; |
| 25 | } |
| 26 | if ($this->inverseJoinColumns) { |
| 27 | $mapping['joinTable']['inverseJoinColumns'] = $this->inverseJoinColumns; |
| 28 | } |
| 29 | if ($this->joinTableName) { |
| 30 | $mapping['joinTable']['name'] = $this->joinTableName; |
| 31 | } |
| 32 | $cm = $this->builder->getClassMetadata(); |
| 33 | $cm->mapManyToMany($mapping); |
| 34 | return $this->builder; |
| 35 | } |
| 36 | } |
| 37 |