mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Expanded rights to also manage actions instead of just a cruds
This commit is contained in:
@@ -6,7 +6,7 @@ use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Entity\Meta\Right;
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -28,7 +28,7 @@ final class ImpressumFixtureSource extends AbstractFixtureSource
|
||||
$right = new Right();
|
||||
$right->setSource($impressumSource);
|
||||
$right->setLayer(LayerType::SOURCE);
|
||||
$right->setCrud(CRUDType::READ);
|
||||
$right->setActionType(ActionType::READ);
|
||||
$right->setLaw($impressumSource->getLaw());
|
||||
$impressumSource->getLaw()->getRights()->add($right);
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -51,7 +51,7 @@ class RequestedAction extends RequestedUser implements RequestedActionInterface
|
||||
private function setRequestedRightCrudType(string $actionType): void
|
||||
{
|
||||
$crudType = $this->getCrudType($actionType);
|
||||
$this->requestedRight->setCrud($crudType);
|
||||
$this->requestedRight->setActionType($crudType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -78,21 +78,21 @@ abstract class AbstractRequestedRightFacade implements RequestedRightInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Attribut\CrudAttributInterface::setCrud()
|
||||
* @see \Infinito\Attribut\ActionTypeAttributInterface::setActionType()
|
||||
*/
|
||||
public function setCrud(string $crud): void
|
||||
public function setActionType(string $actionType): void
|
||||
{
|
||||
$this->requestedRight->setCrud($crud);
|
||||
$this->requestedRight->setActionType($actionType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Attribut\CrudAttributInterface::getCrud()
|
||||
* @see \Infinito\Attribut\ActionTypeAttributInterface::getActionType()
|
||||
*/
|
||||
public function getCrud(): string
|
||||
public function getActionType(): string
|
||||
{
|
||||
return $this->requestedRight->getCrud();
|
||||
return $this->requestedRight->getActionType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,6 @@
|
||||
namespace Infinito\Domain\RequestManagement\Right;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Attribut\CrudAttribut;
|
||||
use Infinito\Attribut\LayerAttribut;
|
||||
use Infinito\Attribut\RecieverAttribut;
|
||||
use Infinito\Exception\PreconditionFailedException;
|
||||
@@ -12,6 +11,7 @@ use Infinito\Attribut\RequestedEntityAttribut;
|
||||
use Infinito\Entity\Meta\MetaInterface;
|
||||
use Infinito\Exception\NotCorrectInstanceException;
|
||||
use Infinito\Domain\RequestManagement\Entity\RequestedEntity;
|
||||
use Infinito\Attribut\ActionTypeAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -20,7 +20,7 @@ use Infinito\Domain\RequestManagement\Entity\RequestedEntity;
|
||||
*/
|
||||
class RequestedRight implements RequestedRightInterface
|
||||
{
|
||||
use CrudAttribut, LayerAttribut, RecieverAttribut, RequestedEntityAttribut;
|
||||
use ActionTypeAttribut, LayerAttribut, RecieverAttribut, RequestedEntityAttribut;
|
||||
|
||||
/**
|
||||
* @var SourceInterface
|
||||
|
@@ -2,16 +2,16 @@
|
||||
|
||||
namespace Infinito\Domain\RequestManagement\Right;
|
||||
|
||||
use Infinito\Attribut\CrudAttributInterface;
|
||||
use Infinito\Attribut\RecieverAttributInterface;
|
||||
use Infinito\Attribut\LayerAttributInterface;
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Attribut\RequestedEntityAttributInterface;
|
||||
use Infinito\Attribut\ActionTypeAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedRightInterface extends CrudAttributInterface, RecieverAttributInterface, LayerAttributInterface, RequestedEntityAttributInterface
|
||||
interface RequestedRightInterface extends ActionTypeAttributInterface, RecieverAttributInterface, LayerAttributInterface, RequestedEntityAttributInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@@ -60,7 +60,7 @@ final class RightChecker implements RightCheckerInterface
|
||||
*/
|
||||
private function isTypeEqual(string $type): bool
|
||||
{
|
||||
return $this->right->getCrud() === $type;
|
||||
return $this->right->getActionType() === $type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user