Expanded rights to also manage actions instead of just a cruds

This commit is contained in:
Kevin Frantz
2019-02-21 18:46:57 +01:00
parent 465d6d6d01
commit 3e91aed050
27 changed files with 91 additions and 98 deletions

View File

@@ -49,9 +49,9 @@ final class LawPermissionChecker implements LawPermissionCheckerInterface
*
* @return Collection|RightInterface[]
*/
private function getRightsByCrud(Collection $rights, string $type): Collection
private function getRightsByActionType(Collection $rights, string $type): Collection
{
return $this->getFilteredRights($rights, $type, 'Crud');
return $this->getFilteredRights($rights, $type, 'ActionType');
}
/**
@@ -149,7 +149,7 @@ final class LawPermissionChecker implements LawPermissionCheckerInterface
$right = $rights[0];
$rightChecker = new RightChecker($right);
return $rightChecker->isGranted($client->getLayer(), $client->getCrud(), $client->getReciever());
return $rightChecker->isGranted($client->getLayer(), $client->getActionType(), $client->getReciever());
}
/**
@@ -168,7 +168,7 @@ final class LawPermissionChecker implements LawPermissionCheckerInterface
public function hasPermission(RightInterface $clientRight): bool
{
$rights = clone $this->law->getRights();
$rights = $this->getRightsByCrud($rights, $clientRight->getCrud());
$rights = $this->getRightsByActionType($rights, $clientRight->getActionType());
$rights = $this->getRightsByLayer($rights, $clientRight->getLayer());
$rights = $this->getRightsByReciever($rights, $clientRight);
$rights = $this->sortByPriority($rights);