From 92886a14ce610829bcc0ec61b2b41aff44372624 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Thu, 13 Sep 2018 16:37:33 +0200 Subject: [PATCH] Optimized law draft --- .../Entity/Attribut/RightAttributInterface.php | 2 +- .../Entity/Attribut/RightsAttributInterface.php | 2 +- .../src/Entity/Attribut/RightsAttribute.php | 2 +- application/src/Entity/Attribut/TypeAttribut.php | 2 +- .../src/Entity/Attribut/TypeAttributInterface.php | 2 +- application/src/Entity/Law.php | 15 ++++++++++++--- application/src/Entity/LawInterface.php | 2 +- application/src/Entity/Right.php | 13 +++++++++++-- application/src/Entity/RightInterface.php | 3 ++- 9 files changed, 31 insertions(+), 12 deletions(-) diff --git a/application/src/Entity/Attribut/RightAttributInterface.php b/application/src/Entity/Attribut/RightAttributInterface.php index 3c65319..80fb30a 100644 --- a/application/src/Entity/Attribut/RightAttributInterface.php +++ b/application/src/Entity/Attribut/RightAttributInterface.php @@ -1,5 +1,5 @@ type = $type; } diff --git a/application/src/Entity/Attribut/TypeAttributInterface.php b/application/src/Entity/Attribut/TypeAttributInterface.php index afbf8cd..7418722 100644 --- a/application/src/Entity/Attribut/TypeAttributInterface.php +++ b/application/src/Entity/Attribut/TypeAttributInterface.php @@ -8,7 +8,7 @@ namespace App\Entity\Attribut; */ interface TypeAttributInterface { - public function setType(string $right):void; + public function setType(string $type):void; public function getType():string; } diff --git a/application/src/Entity/Law.php b/application/src/Entity/Law.php index fe45a55..f74b01d 100644 --- a/application/src/Entity/Law.php +++ b/application/src/Entity/Law.php @@ -2,9 +2,10 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; -use Entity\Attribut\RightsAttribute; +use App\Entity\Attribut\RightsAttribute; use Doctrine\Common\Collections\ArrayCollection; use App\DBAL\Types\RightType; +use App\Entity\Attribut\NodeAttribut; /** * @@ -14,7 +15,7 @@ use App\DBAL\Types\RightType; */ class Law extends AbstractEntity implements LawInterface { - use RightsAttribute; + use RightsAttribute, NodeAttribut; /** * @@ -23,17 +24,25 @@ class Law extends AbstractEntity implements LawInterface */ protected $rights; + /** + * @ORM\OneToOne(targetEntity="Node",cascade={"persist", "remove"}) + * @ORM\JoinColumn(name="node_id", referencedColumnName="id") + * @var NodeInterface + */ + protected $node; + public function __construct() { - parent::__contruct(); $this->initAllRights(); } private function initAllRights(): void { + $this->rights = new ArrayCollection(); foreach (RightType::getChoices() as $key=>$value){ $right = new Right(); $right->setType($value); + $right->setLaw($this); $this->rights->set($key, $right); } } diff --git a/application/src/Entity/LawInterface.php b/application/src/Entity/LawInterface.php index aa9cd0b..0a119d6 100644 --- a/application/src/Entity/LawInterface.php +++ b/application/src/Entity/LawInterface.php @@ -1,7 +1,7 @@