From b9f483bf7f32b6db0d589db3d12fe7885091b00e Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Thu, 13 Sep 2018 15:55:48 +0200 Subject: [PATCH] Optimized law draft --- application/config/packages/doctrine.yaml | 3 +- application/src/DBAL/Types/RightType.php | 25 +++++++++++++ .../Attribut/RightAttributInterface.php | 6 ++-- .../Attribut/RightsAttributInterface.php | 17 +++++++++ .../src/Entity/Attribut/RightsAttribute.php | 26 ++++++++++++++ .../src/Entity/Attribut/TypeAttribut.php | 24 +++++++++++++ .../Entity/Attribut/TypeAttributInterface.php | 15 ++++++++ application/src/Entity/Law.php | 35 ++++++++++++++++--- application/src/Entity/LawInterface.php | 5 +-- application/src/Entity/Node.php | 15 ++++++++ .../src/Entity/PermissionInterface.php | 1 + application/src/Entity/Right.php | 34 ++++++++++++++++++ application/src/Entity/RightInterface.php | 12 +++++-- 13 files changed, 206 insertions(+), 12 deletions(-) create mode 100644 application/src/DBAL/Types/RightType.php create mode 100644 application/src/Entity/Attribut/RightsAttributInterface.php create mode 100644 application/src/Entity/Attribut/RightsAttribute.php create mode 100644 application/src/Entity/Attribut/TypeAttribut.php create mode 100644 application/src/Entity/Attribut/TypeAttributInterface.php create mode 100644 application/src/Entity/Right.php diff --git a/application/config/packages/doctrine.yaml b/application/config/packages/doctrine.yaml index cc74c69..f7fbb4e 100644 --- a/application/config/packages/doctrine.yaml +++ b/application/config/packages/doctrine.yaml @@ -14,8 +14,9 @@ doctrine: default_table_options: charset: utf8mb4 collate: utf8mb4_unicode_ci - url: '%env(resolve:DATABASE_URL)%' + types: + RightType: App\DBAL\Types\RightType orm: auto_generate_proxy_classes: '%kernel.debug%' naming_strategy: doctrine.orm.naming_strategy.underscore diff --git a/application/src/DBAL/Types/RightType.php b/application/src/DBAL/Types/RightType.php new file mode 100644 index 0000000..9a24ef4 --- /dev/null +++ b/application/src/DBAL/Types/RightType.php @@ -0,0 +1,25 @@ + 'administration', + self::READ => 'read', + self::WRITE=>'write', + ]; +} + diff --git a/application/src/Entity/Attribut/RightAttributInterface.php b/application/src/Entity/Attribut/RightAttributInterface.php index 96636d7..3c65319 100644 --- a/application/src/Entity/Attribut/RightAttributInterface.php +++ b/application/src/Entity/Attribut/RightAttributInterface.php @@ -1,6 +1,8 @@ rights = $rights; + } + + public function getRights():ArrayCollection{ + return $this->rights; + } +} + diff --git a/application/src/Entity/Attribut/TypeAttribut.php b/application/src/Entity/Attribut/TypeAttribut.php new file mode 100644 index 0000000..a4cc116 --- /dev/null +++ b/application/src/Entity/Attribut/TypeAttribut.php @@ -0,0 +1,24 @@ +type = $type; + } + + public function getType():string{ + return $this->type; + } +} + diff --git a/application/src/Entity/Attribut/TypeAttributInterface.php b/application/src/Entity/Attribut/TypeAttributInterface.php new file mode 100644 index 0000000..afbf8cd --- /dev/null +++ b/application/src/Entity/Attribut/TypeAttributInterface.php @@ -0,0 +1,15 @@ +initAllRights(); + } + + private function initAllRights(): void + { + foreach (RightType::getChoices() as $key=>$value){ + $right = new Right(); + $right->setType($value); + $this->rights->set($key, $right); + } + } + } diff --git a/application/src/Entity/LawInterface.php b/application/src/Entity/LawInterface.php index 6bec9f7..aa9cd0b 100644 --- a/application/src/Entity/LawInterface.php +++ b/application/src/Entity/LawInterface.php @@ -1,14 +1,15 @@ law = new Law(); + $this->law->setNode($this); } } diff --git a/application/src/Entity/PermissionInterface.php b/application/src/Entity/PermissionInterface.php index c25c029..9ce197d 100644 --- a/application/src/Entity/PermissionInterface.php +++ b/application/src/Entity/PermissionInterface.php @@ -11,5 +11,6 @@ use Entity\Attribut\WhitelistAttributInterface; */ interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface { + } diff --git a/application/src/Entity/Right.php b/application/src/Entity/Right.php new file mode 100644 index 0000000..24de0d9 --- /dev/null +++ b/application/src/Entity/Right.php @@ -0,0 +1,34 @@ +