From a4fdb07cb6c8790a6193f3c9d16f3110bba369cd Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Fri, 21 Sep 2018 13:15:59 +0200 Subject: [PATCH] Added logic draft and optimized rights --- application/src/DBAL/Types/LayerType.php | 23 +++++++++ application/src/DBAL/Types/RightType.php | 3 -- application/src/Entity/AbstractOperation.php | 38 ++++++++++++++ application/src/Entity/AndOperation.php | 32 ++++++++++++ .../src/Logic/Operation/OperandInterface.php | 19 +++++++ .../Logic/Operation/OperationInterface.php | 26 ++++++++++ application/src/Logic/Result/Result.php | 49 +++++++++++++++++++ .../src/Logic/Result/ResultInterface.php | 39 +++++++++++++++ 8 files changed, 226 insertions(+), 3 deletions(-) create mode 100644 application/src/DBAL/Types/LayerType.php create mode 100644 application/src/Entity/AbstractOperation.php create mode 100644 application/src/Entity/AndOperation.php create mode 100644 application/src/Logic/Operation/OperandInterface.php create mode 100644 application/src/Logic/Operation/OperationInterface.php create mode 100644 application/src/Logic/Result/Result.php create mode 100644 application/src/Logic/Result/ResultInterface.php diff --git a/application/src/DBAL/Types/LayerType.php b/application/src/DBAL/Types/LayerType.php new file mode 100644 index 0000000..71dae8c --- /dev/null +++ b/application/src/DBAL/Types/LayerType.php @@ -0,0 +1,23 @@ + 'node', + self::LAW =>'law', + self::SOURCE => 'source', + ]; +} diff --git a/application/src/DBAL/Types/RightType.php b/application/src/DBAL/Types/RightType.php index ef5373f..01fd0c3 100644 --- a/application/src/DBAL/Types/RightType.php +++ b/application/src/DBAL/Types/RightType.php @@ -9,14 +9,11 @@ use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType; */ final class RightType extends AbstractEnumType { - public const ADMINISTRATION = 'administration'; - public const READ = 'read'; public const WRITE = 'write'; protected static $choices = [ - self::ADMINISTRATION => 'administration', self::READ => 'read', self::WRITE => 'write', ]; diff --git a/application/src/Entity/AbstractOperation.php b/application/src/Entity/AbstractOperation.php new file mode 100644 index 0000000..880e2c6 --- /dev/null +++ b/application/src/Entity/AbstractOperation.php @@ -0,0 +1,38 @@ +result; + } + + public function setOperators(ArrayCollection $operands): void + { + $this->operands = $operands; + } +} + diff --git a/application/src/Entity/AndOperation.php b/application/src/Entity/AndOperation.php new file mode 100644 index 0000000..e8a1c54 --- /dev/null +++ b/application/src/Entity/AndOperation.php @@ -0,0 +1,32 @@ +operands->isEmpty()){ + throw new \Exception("Operands must be defined!"); + } + $this->result = new Result(); + /** + * @var OperandInterface $operand + */ + foreach ($this->operands->toArray() as $operand){ + if(!$operand->getResult()->getBool()){ + $this->result->setAll(false); + return; + } + } + $this->result->setAll(true); + } +} + diff --git a/application/src/Logic/Operation/OperandInterface.php b/application/src/Logic/Operation/OperandInterface.php new file mode 100644 index 0000000..5cb19f6 --- /dev/null +++ b/application/src/Logic/Operation/OperandInterface.php @@ -0,0 +1,19 @@ +value; + } + + public function getBool(): bool + { + return $this->bool; + } + + public function setBool(bool $bool): void + { + $this->bool = $bool; + } + + public function setValue($value): void + { + $this->value = $value; + } + + public function setAll($value): void + { + $this->bool = (bool)$value; + $this->value = $value; + } + +} + diff --git a/application/src/Logic/Result/ResultInterface.php b/application/src/Logic/Result/ResultInterface.php new file mode 100644 index 0000000..73958ce --- /dev/null +++ b/application/src/Logic/Result/ResultInterface.php @@ -0,0 +1,39 @@ +