From 5be4b7df3c424136c54d87b86949992beddbe396 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sat, 24 Nov 2018 22:16:34 +0100 Subject: [PATCH] Added drafts --- .../LawPermissionCheckerService.php | 117 ++++++++++++++++++ .../LawPermissionCheckerServiceInterface.php | 26 ++++ 2 files changed, 143 insertions(+) create mode 100644 application/src/Domain/LawManagement/LawPermissionCheckerService.php create mode 100644 application/src/Domain/LawManagement/LawPermissionCheckerServiceInterface.php diff --git a/application/src/Domain/LawManagement/LawPermissionCheckerService.php b/application/src/Domain/LawManagement/LawPermissionCheckerService.php new file mode 100644 index 0000000..e2412cc --- /dev/null +++ b/application/src/Domain/LawManagement/LawPermissionCheckerService.php @@ -0,0 +1,117 @@ +getType() === $this->permissionType) { + $result->add($right); + } + } + + return $result; + } + + private function getRightsByClient(Collection $rights): Collection + { + $result = new ArrayCollection(); + /* + * @var RightInterface + */ + foreach ($rights as $right) { + if ($right->getReciever() === $this->clientSource) { + $result->add($right); + } + } + + return $result; + } + + /** + * @todo Implement + * + * @return CollectionInterface the sources to which the client belongs to + */ + private function getAllClientMemberships(): Collection + { + } + + private function sortByPriority(Collection $rights): Collection + { + } + + /** + * @todo Implement priority function for locking + * + * @param CollectionInterface $rights the rights which exist + * + * @return bool + */ + private function isGranted(CollectionInterface $rights): bool + { + /* + * @var RightInterface + */ + foreach ($rights as $right) { + if ($clientSources->contains($right)) { + } + } + + return $result; + } + + public function checkPermission(): bool + { + $requestedSourceRights = $this->requestedSource->getLaw()->getRights(); + $rightsByPermission = $this->getRightsByPermission($requestedSourceRights); + $rightsbyClient = $this->getRightsByClient($rightsByPermission); + } + + public function setClientSource(SourceInterface $clientSource): void + { + $this->clientSource = $clientSource; + } + + public function setRequestedSource(SourceInterface $requestedSource): void + { + $this->requestedSource = $requestedSource; + } + + public function setType(string $type): void + { + $this->permissionType = $type; + } +} diff --git a/application/src/Domain/LawManagement/LawPermissionCheckerServiceInterface.php b/application/src/Domain/LawManagement/LawPermissionCheckerServiceInterface.php new file mode 100644 index 0000000..b8cc554 --- /dev/null +++ b/application/src/Domain/LawManagement/LawPermissionCheckerServiceInterface.php @@ -0,0 +1,26 @@ +