From 261b7040170ae3967228b0ae9457b377db5d1a71 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Thu, 6 Sep 2018 14:52:01 +0200 Subject: [PATCH] Optimized ORM Modell --- application/src/Entity/AbstractSource.php | 7 +++++-- application/src/Entity/Attribut/SourceAttribut.php | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/application/src/Entity/AbstractSource.php b/application/src/Entity/AbstractSource.php index 88decc4..d716293 100644 --- a/application/src/Entity/AbstractSource.php +++ b/application/src/Entity/AbstractSource.php @@ -6,10 +6,13 @@ use App\Entity\Attribut\NodeAttribut; use Doctrine\ORM\Mapping as ORM; /** - * + * * @author kevinfrantz * @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html - * + * @ORM\Entity + * @ORM\InheritanceType("JOINED") + * @ORM\DiscriminatorColumn(name="discr", type="string") + * @ORM\DiscriminatorMap({"user" = "User"}) */ abstract class AbstractSource implements SourceInterface { diff --git a/application/src/Entity/Attribut/SourceAttribut.php b/application/src/Entity/Attribut/SourceAttribut.php index 8642ee4..0ce4567 100644 --- a/application/src/Entity/Attribut/SourceAttribut.php +++ b/application/src/Entity/Attribut/SourceAttribut.php @@ -10,6 +10,8 @@ use App\Entity\SourceInterface; */ trait SourceAttribut { /** + * @ORM\OneToOne(targetEntity="AbstractSource") + * @ORM\JoinColumn(name="source_id", referencedColumnName="id") * @var SourceInterface */ protected $source;