diff --git a/application/src/Entity/Meta/LawInterface.php b/application/src/Entity/Meta/LawInterface.php index 604218a..7a08e66 100644 --- a/application/src/Entity/Meta/LawInterface.php +++ b/application/src/Entity/Meta/LawInterface.php @@ -8,6 +8,6 @@ use App\Entity\Method\GrantedInterface; /** * @author kevinfrantz */ -interface LawInterface extends RightsAttributInterface,GrantedInterface, MetaInterface +interface LawInterface extends RightsAttributInterface, GrantedInterface, MetaInterface { } diff --git a/application/src/Entity/Meta/Reciever.php b/application/src/Entity/Meta/Reciever.php index fc66b37..b2e2a3b 100644 --- a/application/src/Entity/Meta/Reciever.php +++ b/application/src/Entity/Meta/Reciever.php @@ -4,10 +4,9 @@ namespace App\Entity\Meta; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; -use App\Entity\Attribut\RelationAttribut; -use App\Entity\Attribut\RelationAttributInterface; use App\Entity\Attribut\MembersAttribut; use App\Entity\Source\SourceInterface; +use App\Entity\Attribut\RightAttribut; /** * @author kevinfrantz @@ -16,17 +15,17 @@ use App\Entity\Source\SourceInterface; */ class Reciever extends AbstractMeta implements RecieverInterface { - use RelationAttribut, MembersAttribut; + use RightAttribut, MembersAttribut; /** - * The node for which the right exists. + * The right which the reciever group belongs to. * - * @ORM\ManyToOne(targetEntity="Relation") - * @ORM\JoinColumn(name="relation_id", referencedColumnName="id") + * @ORM\OneToOne(targetEntity="Right",cascade={"persist", "remove"}) + * @ORM\JoinColumn(name="right_id", referencedColumnName="id") * - * @var RelationAttributInterface + * @var RightInterface */ - protected $relation; + protected $right; /** * @ORM\ManyToMany(targetEntity="App\Entity\Source\AbstractSource") diff --git a/application/src/Entity/Meta/RecieverInterface.php b/application/src/Entity/Meta/RecieverInterface.php index 7f81f28..9138ca8 100644 --- a/application/src/Entity/Meta/RecieverInterface.php +++ b/application/src/Entity/Meta/RecieverInterface.php @@ -2,14 +2,14 @@ namespace App\Entity\Meta; -use App\Entity\Attribut\RelationAttributInterface; use App\Entity\Attribut\MembersAttributInterface; +use App\Entity\Attribut\RightAttributInterface; /** * It's neccessary to have an own reciever class, because if you would use a GroupSource it would lead to an infinite loop. * * @author kevinfrantz */ -interface RecieverInterface extends RelationAttributInterface, MetaInterface, MembersAttributInterface +interface RecieverInterface extends MetaInterface, MembersAttributInterface, RightAttributInterface { } diff --git a/application/src/Entity/Meta/Right.php b/application/src/Entity/Meta/Right.php index ce05afc..5afc017 100644 --- a/application/src/Entity/Meta/Right.php +++ b/application/src/Entity/Meta/Right.php @@ -56,14 +56,6 @@ final class Right extends AbstractMeta implements RightInterface */ protected $grant; - /** - * @ORM\ManyToOne(targetEntity="Relation") - * @ORM\JoinColumn(name="relation_id", referencedColumnName="id") - * - * @var RelationInterface - */ - protected $relation; - /** * @ORM\Column(name="type", type="RightType", nullable=false) * @DoctrineAssert\Enum(entity="App\DBAL\Types\RightType") @@ -84,6 +76,7 @@ final class Right extends AbstractMeta implements RightInterface { parent::__construct(); $this->grant = true; + $this->reciever = new Reciever(); } public function isGranted(SourceInterface $source, string $layer, string $right): bool diff --git a/application/src/Entity/Method/GrantedInterface.php b/application/src/Entity/Method/GrantedInterface.php index 5e7c4a3..92b0fbd 100644 --- a/application/src/Entity/Method/GrantedInterface.php +++ b/application/src/Entity/Method/GrantedInterface.php @@ -11,8 +11,10 @@ interface GrantedInterface { /** * Returns true if the source is granted access to the layer with the requested right. + * * @param SourceInterface $source - * @param string $right + * @param string $right + * * @return bool */ public function isGranted(SourceInterface $source, string $layer, string $right): bool; diff --git a/application/tests/Unit/Entity/Meta/RecieverTest.php b/application/tests/Unit/Entity/Meta/RecieverTest.php index 1efa455..db99af0 100644 --- a/application/tests/Unit/Entity/Meta/RecieverTest.php +++ b/application/tests/Unit/Entity/Meta/RecieverTest.php @@ -22,5 +22,7 @@ class RecieverTest extends TestCase public function testConstructor(): void { $this->assertInstanceOf(Collection::class, $this->reciever->getMembers()); + $this->expectException(\TypeError::class); + $this->reciever->getRight(); } } diff --git a/application/tests/Unit/Entity/Meta/RightTest.php b/application/tests/Unit/Entity/Meta/RightTest.php index 13b5013..3431af7 100644 --- a/application/tests/Unit/Entity/Meta/RightTest.php +++ b/application/tests/Unit/Entity/Meta/RightTest.php @@ -7,6 +7,7 @@ use App\DBAL\Types\RightType; use App\Entity\Meta\RightInterface; use App\Entity\Meta\Right; use App\Entity\Meta\Law; +use App\Entity\Meta\RecieverInterface; /** * @todo Implement reciever test @@ -27,8 +28,10 @@ class RightTest extends TestCase public function testConstructor(): void { + $this->assertInstanceOf(RecieverInterface::class, $this->right->getReciever()); $this->expectException(\TypeError::class); $this->assertNull($this->right->getLaw()); + $this->expectException(\TypeError::class); $this->assertNull($this->right->getType()); }