mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Added grant to all function to RightChecker and LawPermissionChecker
This commit is contained in:
@@ -54,17 +54,27 @@ final class LawPermissionChecker implements LawPermissionCheckerInterface
|
||||
return $this->getFilteredRights($rights, $type, 'Crud');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RightInterface $right
|
||||
*
|
||||
* @return bool True if right applies to all
|
||||
*/
|
||||
private function doesRightApplyToAll(RightInterface $right): bool
|
||||
{
|
||||
return !$right->hasReciever();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection|RightInterface[] $rights
|
||||
* @param SourceInterface $reciever
|
||||
* @param RightInterface $requestedRight
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getRightsByReciever(Collection $rights, SourceInterface $reciever): Collection
|
||||
private function getRightsByReciever(Collection $rights, RightInterface $requestedRight): Collection
|
||||
{
|
||||
$result = new ArrayCollection();
|
||||
foreach ($rights as $right) {
|
||||
if ($right->getReciever() === $reciever || $this->memberExist($right, $reciever)) {
|
||||
if ($this->doesRightApplyToAll($right) || $right->getReciever() === $requestedRight->getReciever() || $this->memberExist($right, $requestedRight->getReciever())) {
|
||||
$result->add($right);
|
||||
}
|
||||
}
|
||||
@@ -160,7 +170,7 @@ final class LawPermissionChecker implements LawPermissionCheckerInterface
|
||||
$rights = clone $this->law->getRights();
|
||||
$rights = $this->getRightsByCrud($rights, $clientRight->getCrud());
|
||||
$rights = $this->getRightsByLayer($rights, $clientRight->getLayer());
|
||||
$rights = $this->getRightsByReciever($rights, $clientRight->getReciever());
|
||||
$rights = $this->getRightsByReciever($rights, $clientRight);
|
||||
$rights = $this->sortByPriority($rights);
|
||||
|
||||
return $this->isGranted($rights, $clientRight);
|
||||
|
Reference in New Issue
Block a user