Added grant to all function to RightChecker and LawPermissionChecker

This commit is contained in:
Kevin Frantz
2019-02-16 16:16:48 +01:00
parent 6f6b720470
commit 256e37ccd5
12 changed files with 130 additions and 11 deletions

View File

@@ -71,6 +71,24 @@ final class RightChecker implements RightCheckerInterface
return $this->right->getGrant();
}
/**
* @return bool
*/
private function doesRightApplyToAllSources(): bool
{
return !$this->right->hasReciever();
}
/**
* @param SourceInterface $source
*
* @return bool
*/
private function doesRightApply(SourceInterface $source): bool
{
return $this->doesRightApplyToAllSources() || $this->hasClientSource($source);
}
/**
* @param RightInterface $right
*/
@@ -79,8 +97,13 @@ final class RightChecker implements RightCheckerInterface
$this->right = $right;
}
/**
* {@inheritdoc}
*
* @see \App\Domain\RightManagement\RightCheckerInterface::isGranted()
*/
public function isGranted(string $layer, string $type, SourceInterface $source): bool
{
return $this->isLayerEqual($layer) && $this->isTypeEqual($type) && $this->hasClientSource($source) && $this->checkPermission();
return $this->isLayerEqual($layer) && $this->isTypeEqual($type) && $this->doesRightApply($source) && $this->checkPermission();
}
}