diff --git a/application/config/packages/doctrine.yaml b/application/config/packages/doctrine.yaml index 816f889..3a349de 100644 --- a/application/config/packages/doctrine.yaml +++ b/application/config/packages/doctrine.yaml @@ -17,7 +17,6 @@ doctrine: url: '%env(resolve:DATABASE_URL)%' types: RightType: App\DBAL\Types\RightType - RecieverType: App\DBAL\Types\RecieverType LayerType: App\DBAL\Types\LayerType orm: auto_generate_proxy_classes: '%kernel.debug%' diff --git a/application/src/DBAL/Types/RecieverType.php b/application/src/DBAL/Types/RecieverType.php deleted file mode 100644 index 3a42b4f..0000000 --- a/application/src/DBAL/Types/RecieverType.php +++ /dev/null @@ -1,26 +0,0 @@ - 'node', - self::PARENTS => 'parents', - self::CHILDREN => 'children', - self::SIBLINGS => 'siblings', - ]; -} diff --git a/application/src/Entity/Attribut/RecieverAttribut.php b/application/src/Entity/Attribut/RecieverAttribut.php index be92e6b..6dd0394 100644 --- a/application/src/Entity/Attribut/RecieverAttribut.php +++ b/application/src/Entity/Attribut/RecieverAttribut.php @@ -2,22 +2,24 @@ namespace App\Entity\Attribut; +use App\Entity\Meta\RecieverInterface; + /** * @author kevinfrantz */ trait RecieverAttribut { /** - * @var string + * @var RecieverInterface */ protected $reciever; - public function setReciever(string $type): void + public function setReciever(RecieverInterface $recieverGroup): void { - $this->reciever = $type; + $this->reciever = $recieverGroup; } - public function getReciever(): string + public function getReciever(): RecieverInterface { return $this->reciever; } diff --git a/application/src/Entity/Attribut/RecieverAttributInterface.php b/application/src/Entity/Attribut/RecieverAttributInterface.php index 0085ea9..08e4ed7 100644 --- a/application/src/Entity/Attribut/RecieverAttributInterface.php +++ b/application/src/Entity/Attribut/RecieverAttributInterface.php @@ -2,12 +2,14 @@ namespace App\Entity\Attribut; +use App\Entity\Meta\RecieverInterface; + /** * @author kevinfrantz */ interface RecieverAttributInterface { - public function setReciever(string $type): void; + public function setReciever(RecieverInterface $recieverGroup): void; - public function getReciever(): string; + public function getReciever(): RecieverInterface; } diff --git a/application/src/Entity/Attribut/RecieverGroupAttribut.php b/application/src/Entity/Attribut/RecieverGroupAttribut.php deleted file mode 100644 index aae2a1f..0000000 --- a/application/src/Entity/Attribut/RecieverGroupAttribut.php +++ /dev/null @@ -1,26 +0,0 @@ -recieverGroup = $recieverGroup; - } - - public function getRecieverGroup(): RecieverGroupInterface - { - return $this->recieverGroup; - } -} diff --git a/application/src/Entity/Attribut/RecieverGroupAttributInterface.php b/application/src/Entity/Attribut/RecieverGroupAttributInterface.php deleted file mode 100644 index 1c9e043..0000000 --- a/application/src/Entity/Attribut/RecieverGroupAttributInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -reciever) { - case RecieverType::PARENTS: - return $this->node->getParents(); - case RecieverType::NODE: - return new ArrayCollection([$this->node]); - case RecieverType::CHILDREN: - return $this->node->getChilds(); - } - throw new NotImplementedException('Reciever '.$this->reciever.' not implemented.'); - } -} diff --git a/application/src/Entity/Meta/RecieverGroupInterface.php b/application/src/Entity/Meta/RecieverInterface.php similarity index 58% rename from application/src/Entity/Meta/RecieverGroupInterface.php rename to application/src/Entity/Meta/RecieverInterface.php index 9c722ca..6cf653e 100644 --- a/application/src/Entity/Meta/RecieverGroupInterface.php +++ b/application/src/Entity/Meta/RecieverInterface.php @@ -2,14 +2,13 @@ namespace App\Entity\Meta; -use App\Entity\Attribut\RecieverAttributInterface; use Doctrine\Common\Collections\ArrayCollection; use App\Entity\Attribut\RelationAttributInterface; /** * @author kevinfrantz */ -interface RecieverGroupInterface extends RelationAttributInterface, RecieverAttributInterface, MetaInterface +interface RecieverInterface extends RelationAttributInterface, MetaInterface { public function getAllRecievers(): ArrayCollection; } diff --git a/application/src/Entity/Meta/Right.php b/application/src/Entity/Meta/Right.php index f59edde..1382aa3 100644 --- a/application/src/Entity/Meta/Right.php +++ b/application/src/Entity/Meta/Right.php @@ -11,7 +11,7 @@ use App\DBAL\Types\RightType; use App\Entity\Attribut\GrantAttribut; use App\Logic\Operation\OperationInterface; use App\Entity\Attribut\ConditionAttribut; -use App\Entity\Attribut\RecieverGroupAttribut; +use App\Entity\Attribut\RecieverAttribut; use App\Entity\Attribut\LayerAttribut; use App\Entity\Attribut\RelationAttribut; @@ -22,7 +22,7 @@ use App\Entity\Attribut\RelationAttribut; */ final class Right extends AbstractMeta implements RightInterface { - use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverGroupAttribut,LayerAttribut; + use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut; /** * @ORM\ManyToOne(targetEntity="Law", inversedBy="rights") @@ -44,9 +44,9 @@ final class Right extends AbstractMeta implements RightInterface * @ORM\OneToOne(targetEntity="RecieverGroup",cascade={"persist", "remove"}) * @ORM\JoinColumn(name="reciever_id", referencedColumnName="id") * - * @var RecieverGroupInterface + * @var RecieverInterface */ - protected $recieverGroup; + protected $reciever; /** * @ORM\Column(type="boolean",name="`grant`") diff --git a/application/src/Entity/Meta/RightInterface.php b/application/src/Entity/Meta/RightInterface.php index 4d6bb4b..6625642 100644 --- a/application/src/Entity/Meta/RightInterface.php +++ b/application/src/Entity/Meta/RightInterface.php @@ -4,7 +4,7 @@ namespace App\Entity\Meta; use App\Entity\Attribut\TypeAttributInterface; use App\Entity\Attribut\LawAttributInterface; -use App\Entity\Attribut\RecieverGroupAttributInterface; +use App\Entity\Attribut\RecieverAttributInterface; use App\Entity\Attribut\GrantAttributInterface; use App\Entity\Attribut\ConditionAttributInterface; use App\Entity\Attribut\LayerAttributInterface; @@ -14,6 +14,6 @@ use App\Entity\Attribut\RelationAttributInterface; /** * @author kevinfrantz */ -interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverGroupAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface +interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface { } diff --git a/application/tests/unit/Entity/AbstractEntityTest.php b/application/tests/unit/Entity/AbstractEntityTest.php index 41b0fe0..7f1fa4f 100644 --- a/application/tests/unit/Entity/AbstractEntityTest.php +++ b/application/tests/unit/Entity/AbstractEntityTest.php @@ -1,8 +1,10 @@ reciever = new Reciever(); + } + + public function testConstructor():void { + $this->assertEquals(Collection::class, $this->reciever->getAllRecievers()); + } +} \ No newline at end of file diff --git a/application/tests/unit/Entity/Meta/RightTest.php b/application/tests/unit/Entity/Meta/RightTest.php index 0c5b8a6..13b5013 100644 --- a/application/tests/unit/Entity/Meta/RightTest.php +++ b/application/tests/unit/Entity/Meta/RightTest.php @@ -1,9 +1,12 @@