/
OneToOneAssociationBuilder.php
33 lines (29 loc) · 1.13 KB
/
OneToOneAssociationBuilder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace Concrete\Core\Express\Association\Builder;
use Concrete\Core\Database\Schema\BuilderInterface;
use Concrete\Core\Entity\Express\OneToOneAssociation;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
class OneToOneAssociationBuilder implements BuilderInterface
{
protected $association;
public function __construct(OneToOneAssociation $association)
{
$this->association = $association;
}
public function build(ClassMetadataBuilder $builder)
{
if ($this->association->getAssociationType() == OneToOneAssociation::TYPE_OWNING) {
$builder->addOwningOneToOne(
$this->association->getComputedTargetPropertyName(),
$this->association->getTargetEntity()->getName(),
$this->association->getComputedInversedByPropertyName()
);
} else {
$builder->addInverseOneToOne(
$this->association->getComputedTargetPropertyName(),
$this->association->getTargetEntity()->getName(),
$this->association->getComputedInversedByPropertyName()
);
}
}
}