From 94bc8c5da454becd27e077daa3683b8baaf36d21 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Wed, 3 Oct 2018 18:20:53 +0200 Subject: [PATCH] Added draft for LawController --- application/src/Controller/LawController.php | 36 +++++++++++++++++++ application/src/Controller/NodeController.php | 1 - .../src/Entity/Attribut/ChildsAttribut.php | 8 ----- .../src/Entity/Attribut/ParentsAttribut.php | 8 ----- application/src/Entity/Law.php | 5 +-- application/src/Entity/Node.php | 28 +++++++++++++-- application/src/Entity/RecieverGroup.php | 2 -- 7 files changed, 63 insertions(+), 25 deletions(-) create mode 100644 application/src/Controller/LawController.php diff --git a/application/src/Controller/LawController.php b/application/src/Controller/LawController.php new file mode 100644 index 0000000..0638c22 --- /dev/null +++ b/application/src/Controller/LawController.php @@ -0,0 +1,36 @@ +createNotFoundException('No node found for id '.$id); } - return $node; } } diff --git a/application/src/Entity/Attribut/ChildsAttribut.php b/application/src/Entity/Attribut/ChildsAttribut.php index 770f907..db3ac5c 100644 --- a/application/src/Entity/Attribut/ChildsAttribut.php +++ b/application/src/Entity/Attribut/ChildsAttribut.php @@ -11,14 +11,6 @@ use Doctrine\Common\Collections\Collection; trait ChildsAttribut { /** - * Many Nodes have many childs. - * - * @ORM\ManyToMany(targetEntity="Node") - * @ORM\JoinTable(name="nodes_childs", - * joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")} - * ) - * * @var Collection|NodeInterface[] */ protected $childs; diff --git a/application/src/Entity/Attribut/ParentsAttribut.php b/application/src/Entity/Attribut/ParentsAttribut.php index 96291b4..e513780 100644 --- a/application/src/Entity/Attribut/ParentsAttribut.php +++ b/application/src/Entity/Attribut/ParentsAttribut.php @@ -11,14 +11,6 @@ use Doctrine\Common\Collections\Collection; trait ParentsAttribut { /** - * Many Nodes have many parents. - * - * @ORM\ManyToMany(targetEntity="Node") - * @ORM\JoinTable(name="nodes_parents", - * joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")} - * ) - * * @var Collection|NodeInterface[] */ protected $parents; diff --git a/application/src/Entity/Law.php b/application/src/Entity/Law.php index e4fb306..d6b6410 100644 --- a/application/src/Entity/Law.php +++ b/application/src/Entity/Law.php @@ -6,8 +6,6 @@ use Doctrine\ORM\Mapping as ORM; use App\Entity\Attribut\RightsAttribute; use Doctrine\Common\Collections\ArrayCollection; use App\Entity\Attribut\NodeAttribut; -use App\Entity\LawInterface; -use App\Entity\NodeInterface; /** * @author kevinfrantz @@ -45,8 +43,7 @@ class Law extends AbstractEntity implements LawInterface public function isGranted(NodeInterface $node, string $layer, string $right): bool { - /* - * + /** * @var RightInterface */ foreach ($this->rights->toArray() as $right) { diff --git a/application/src/Entity/Node.php b/application/src/Entity/Node.php index 07490d2..d00066f 100644 --- a/application/src/Entity/Node.php +++ b/application/src/Entity/Node.php @@ -9,9 +9,8 @@ use App\Entity\Attribut\ParentsAttribut; use App\Entity\Attribut\ChildsAttribut; use App\Entity\Attribut\LawAttribut; use Doctrine\Common\Collections\ArrayCollection; -use App\Entity\NodeInterface; use App\Entity\Source\SourceInterface; -use App\Entity\LawInterface; +use Doctrine\Common\Collections\Collection; /** * @author kevinfrantz @@ -25,6 +24,31 @@ class Node extends AbstractEntity implements NodeInterface ParentsAttribut, LawAttribut, ChildsAttribut; + + /** + * Many Nodes have many parents. + * @ORM\ManyToMany(targetEntity="Node") + * @ORM\JoinTable(name="nodes_parents", + * joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}, + * inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")} + * ) + * + * @var Collection|NodeInterface[] + */ + protected $parents; + + /** + * Many Nodes have many childs. + * + * @ORM\ManyToMany(targetEntity="Node") + * @ORM\JoinTable(name="nodes_childs", + * joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}, + * inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")} + * ) + * + * @var Collection|NodeInterface[] + */ + protected $childs; /** * @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"}) diff --git a/application/src/Entity/RecieverGroup.php b/application/src/Entity/RecieverGroup.php index 2b156fe..5bcdb15 100644 --- a/application/src/Entity/RecieverGroup.php +++ b/application/src/Entity/RecieverGroup.php @@ -9,8 +9,6 @@ use App\DBAL\Types\RecieverType; use Symfony\Component\Intl\Exception\NotImplementedException; use Doctrine\ORM\Mapping as ORM; use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert; -use App\Entity\RecieverGroupInterface; -use App\Entity\NodeInterface; /** * @author kevinfrantz