mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Removed logic from persistence layer
This commit is contained in:
@@ -6,7 +6,6 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Attribut\RightsAttribute;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -25,27 +24,7 @@ final class Law extends AbstractMeta implements LawInterface
|
||||
protected $rights;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->initAllRights();
|
||||
}
|
||||
|
||||
private function initAllRights(): void
|
||||
{
|
||||
$this->rights = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function isGranted(SourceInterface $source, string $layer, string $right): bool
|
||||
{
|
||||
/*
|
||||
*
|
||||
* @var RightInterface
|
||||
*/
|
||||
foreach ($this->rights->toArray() as $right) {
|
||||
if ($right->isGranted($relation, $layer, $right)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -3,11 +3,10 @@
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RightsAttributInterface;
|
||||
use App\Entity\Method\GrantedInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LawInterface extends RightsAttributInterface, GrantedInterface, MetaInterface
|
||||
interface LawInterface extends RightsAttributInterface, MetaInterface
|
||||
{
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Attribut\RightAttribut;
|
||||
use App\Entity\Attribut\CollectionAttribut;
|
||||
use App\Entity\Method\CollectionDimensionHelperMethod;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -16,7 +15,7 @@ use App\Entity\Method\CollectionDimensionHelperMethod;
|
||||
*/
|
||||
class Reciever extends AbstractMeta implements RecieverInterface
|
||||
{
|
||||
use RightAttribut, CollectionAttribut,CollectionDimensionHelperMethod;
|
||||
use RightAttribut, CollectionAttribut;
|
||||
|
||||
/**
|
||||
* The right which the reciever group belongs to.
|
||||
|
@@ -4,13 +4,12 @@ namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RightAttributInterface;
|
||||
use App\Entity\Attribut\CollectionAttributInterface;
|
||||
use App\Helper\DimensionHelperInterface;
|
||||
|
||||
/**
|
||||
* It's neccessary to have an own reciever class, because if you would use a GroupSource it would lead to an infinite loop.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverInterface extends MetaInterface, RightAttributInterface, CollectionAttributInterface, DimensionHelperInterface
|
||||
interface RecieverInterface extends MetaInterface, RightAttributInterface, CollectionAttributInterface
|
||||
{
|
||||
}
|
||||
|
@@ -14,7 +14,6 @@ use App\Entity\Attribut\ConditionAttribut;
|
||||
use App\Entity\Attribut\RecieverAttribut;
|
||||
use App\Entity\Attribut\LayerAttribut;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -79,27 +78,4 @@ final class Right extends AbstractMeta implements RightInterface
|
||||
$this->reciever = new Reciever();
|
||||
$this->reciever->setRight($this);
|
||||
}
|
||||
|
||||
public function isGranted(SourceInterface $source, string $layer, string $right): bool
|
||||
{
|
||||
if ($this->layer == $layer && $this->type == $right && $this->checkIfNodeIsReciever($relation) && $this->getConditionBoolOrTrue()) {
|
||||
return $this->grant;
|
||||
}
|
||||
|
||||
return !($this->grant);
|
||||
}
|
||||
|
||||
private function getConditionBoolOrTrue(): bool
|
||||
{
|
||||
if ($this->hasCondition()) {
|
||||
return $this->condition->getResult()->getBool();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkIfNodeIsReciever(RelationInterface $relation): bool
|
||||
{
|
||||
return $this->recieverGroup->getAllRecievers()->contains($relation);
|
||||
}
|
||||
}
|
||||
|
@@ -8,12 +8,11 @@ use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use App\Entity\Attribut\GrantAttributInterface;
|
||||
use App\Entity\Attribut\ConditionAttributInterface;
|
||||
use App\Entity\Attribut\LayerAttributInterface;
|
||||
use App\Entity\Method\GrantedInterface;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, GrantedInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user