diff --git a/application/src/Entity/AbstractEntity.php b/application/src/Entity/AbstractEntity.php index 9e2543e..fcfbb08 100644 --- a/application/src/Entity/AbstractEntity.php +++ b/application/src/Entity/AbstractEntity.php @@ -20,4 +20,8 @@ class AbstractEntity * @var int */ protected $id; + + protected function __construct() + { + } } diff --git a/application/src/Entity/AbstractSource.php b/application/src/Entity/AbstractSource.php index 55242ab..8993455 100644 --- a/application/src/Entity/AbstractSource.php +++ b/application/src/Entity/AbstractSource.php @@ -27,6 +27,7 @@ abstract class AbstractSource extends AbstractEntity implements SourceInterface public function __construct() { + parent::__construct(); $this->node = new Node(); $this->node->setSource($this); } diff --git a/application/src/Entity/Attribut/ParentAttribut.php b/application/src/Entity/Attribut/ParentAttribut.php index 3266061..be0ede3 100644 --- a/application/src/Entity/Attribut/ParentAttribut.php +++ b/application/src/Entity/Attribut/ParentAttribut.php @@ -1,9 +1,6 @@ parents; + $this->parent = $parent; } - public function setParents(ArrayCollection $parents): void + public function getParent(): ParentAttributInterface { - $this->parents = $parents; + return $this->parent; } } diff --git a/application/src/Entity/Attribut/ParentAttributInterface.php b/application/src/Entity/Attribut/ParentAttributInterface.php new file mode 100644 index 0000000..f13b630 --- /dev/null +++ b/application/src/Entity/Attribut/ParentAttributInterface.php @@ -0,0 +1,13 @@ +parents; + } + + public function setParents(ArrayCollection $parents): void + { + $this->parents = $parents; + } +} diff --git a/application/src/Entity/Attribut/PermissionAttribut.php b/application/src/Entity/Attribut/PermissionAttribut.php new file mode 100644 index 0000000..fcffbb5 --- /dev/null +++ b/application/src/Entity/Attribut/PermissionAttribut.php @@ -0,0 +1,26 @@ +permissions = $permissions; + } + + public function getPermissions(): ArrayCollection + { + return $this->permissions; + } +} diff --git a/application/src/Entity/Attribut/PermissionsAttributInterface.php b/application/src/Entity/Attribut/PermissionsAttributInterface.php new file mode 100644 index 0000000..700c72e --- /dev/null +++ b/application/src/Entity/Attribut/PermissionsAttributInterface.php @@ -0,0 +1,15 @@ +right = $right; + } + + public function getRight(): RightInterface + { + return $this->getRight(); + } +} diff --git a/application/src/Entity/Node.php b/application/src/Entity/Node.php index f2c4406..e769942 100644 --- a/application/src/Entity/Node.php +++ b/application/src/Entity/Node.php @@ -5,7 +5,7 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use App\Entity\Attribut\IdAttribut; use App\Entity\Attribut\SourceAttribut; -use App\Entity\Attribut\ParentAttribut; +use App\Entity\Attribut\ParentsAttribut; use App\Entity\Attribut\ChildsAttribut; use App\Entity\Attribut\LawAttribut; @@ -18,7 +18,7 @@ class Node extends AbstractEntity implements NodeInterface { use IdAttribut, SourceAttribut, - ParentAttribut, + ParentsAttribut, LawAttribut, ChildsAttribut; diff --git a/application/src/Entity/Permission.php b/application/src/Entity/Permission.php index 8d673cb..433833d 100644 --- a/application/src/Entity/Permission.php +++ b/application/src/Entity/Permission.php @@ -5,6 +5,8 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use App\Entity\Attribut\BlacklistAttribut; use App\Entity\Attribut\WhitelistAttribut; +use App\Entity\Attribut\NodeAttribut; +use Entity\Attribut\RightAttribut; /** * @author kevinfrantz @@ -13,7 +15,7 @@ use App\Entity\Attribut\WhitelistAttribut; */ class Permission extends AbstractEntity implements PermissionInterface { - use BlacklistAttribut,WhitelistAttribut; + use BlacklistAttribut,WhitelistAttribut,NodeAttribut,RightAttribut; /** * @ORM\Column(type="boolean") @@ -28,4 +30,20 @@ class Permission extends AbstractEntity implements PermissionInterface * @var bool */ protected $whitelist; + + /** + * @ORM\ManyToOne(targetEntity="Node") + * @ORM\JoinColumn(name="node_id", referencedColumnName="id") + * + * @var NodeInterface + */ + protected $node; + + /** + * @ORM\ManyToOne(targetEntity="Right") + * @ORM\JoinColumn(name="right_id", referencedColumnName="id") + * + * @var RightInterface + */ + protected $right; } diff --git a/application/src/Entity/PermissionInterface.php b/application/src/Entity/PermissionInterface.php index 55b1a8d..ec4921b 100644 --- a/application/src/Entity/PermissionInterface.php +++ b/application/src/Entity/PermissionInterface.php @@ -4,10 +4,12 @@ namespace App\Entity; use App\Entity\Attribut\BlacklistAttributInterface; use Entity\Attribut\WhitelistAttributInterface; +use App\Entity\Attribut\NodeAttributInterface; +use App\Entity\Attribut\RightAttributInterface; /** * @author kevinfrantz */ -interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface +interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface, NodeAttributInterface, RightAttributInterface { } diff --git a/application/src/Entity/Right.php b/application/src/Entity/Right.php index fc79b7a..cdb0452 100644 --- a/application/src/Entity/Right.php +++ b/application/src/Entity/Right.php @@ -8,6 +8,7 @@ use App\DBAL\Types\RightType; use Doctrine\ORM\Mapping as ORM; use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert; use App\Entity\Attribut\LawAttribut; +use App\Entity\Attribut\PermissionAttribut; /** * @author kevinfrantz @@ -16,10 +17,10 @@ use App\Entity\Attribut\LawAttribut; */ class Right extends AbstractEntity implements RightInterface { - use TypeAttribut,LawAttribut; + use TypeAttribut,LawAttribut,PermissionAttribut; /** - * @ORM\ManyToOne(targetEntity="Law",cascade={"persist", "remove"}) + * @ORM\ManyToOne(targetEntity="Law") * @ORM\JoinColumn(name="law_id", referencedColumnName="id") * * @var LawInterface @@ -35,7 +36,7 @@ class Right extends AbstractEntity implements RightInterface protected $type; /** - * @ORM\OneToMany(targetEntity="Right", mappedBy="id", cascade={"persist", "remove"}) + * @ORM\OneToMany(targetEntity="Permission", mappedBy="id", cascade={"persist", "remove"}) * * @var ArrayCollection */ @@ -45,7 +46,9 @@ class Right extends AbstractEntity implements RightInterface { } - public function setPermissions(ArrayCollection $permissions): void + public function __construct() { + parent::__construct(); + $this->permissions = new ArrayCollection(); } } diff --git a/application/src/Entity/RightInterface.php b/application/src/Entity/RightInterface.php index 3a9387a..998fb87 100644 --- a/application/src/Entity/RightInterface.php +++ b/application/src/Entity/RightInterface.php @@ -2,16 +2,14 @@ namespace App\Entity; -use Doctrine\Common\Collections\ArrayCollection; use App\Entity\Attribut\TypeAttributInterface; use App\Entity\Attribut\LawAttributInterface; +use App\Entity\Attribut\PermissionsAttributInterface; /** * @author kevinfrantz */ -interface RightInterface extends TypeAttributInterface, LawAttributInterface +interface RightInterface extends TypeAttributInterface, LawAttributInterface, PermissionsAttributInterface { public function isGranted(NodeInterface $node): bool; - - public function setPermissions(ArrayCollection $permissions): void; }