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 @@ +