mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Optimized right and reciever logic
This commit is contained in:
@@ -8,6 +8,6 @@ use App\Entity\Method\GrantedInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LawInterface extends RightsAttributInterface,GrantedInterface, MetaInterface
|
||||
interface LawInterface extends RightsAttributInterface, GrantedInterface, MetaInterface
|
||||
{
|
||||
}
|
||||
|
@@ -4,10 +4,9 @@ namespace App\Entity\Meta;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
use App\Entity\Attribut\MembersAttribut;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Attribut\RightAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -16,17 +15,17 @@ use App\Entity\Source\SourceInterface;
|
||||
*/
|
||||
class Reciever extends AbstractMeta implements RecieverInterface
|
||||
{
|
||||
use RelationAttribut, MembersAttribut;
|
||||
use RightAttribut, MembersAttribut;
|
||||
|
||||
/**
|
||||
* The node for which the right exists.
|
||||
* The right which the reciever group belongs to.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Relation")
|
||||
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
|
||||
* @ORM\OneToOne(targetEntity="Right",cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(name="right_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RelationAttributInterface
|
||||
* @var RightInterface
|
||||
*/
|
||||
protected $relation;
|
||||
protected $right;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="App\Entity\Source\AbstractSource")
|
||||
|
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
use App\Entity\Attribut\MembersAttributInterface;
|
||||
use App\Entity\Attribut\RightAttributInterface;
|
||||
|
||||
/**
|
||||
* 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 RelationAttributInterface, MetaInterface, MembersAttributInterface
|
||||
interface RecieverInterface extends MetaInterface, MembersAttributInterface, RightAttributInterface
|
||||
{
|
||||
}
|
||||
|
@@ -56,14 +56,6 @@ final class Right extends AbstractMeta implements RightInterface
|
||||
*/
|
||||
protected $grant;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Relation")
|
||||
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RelationInterface
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="type", type="RightType", nullable=false)
|
||||
* @DoctrineAssert\Enum(entity="App\DBAL\Types\RightType")
|
||||
@@ -84,6 +76,7 @@ final class Right extends AbstractMeta implements RightInterface
|
||||
{
|
||||
parent::__construct();
|
||||
$this->grant = true;
|
||||
$this->reciever = new Reciever();
|
||||
}
|
||||
|
||||
public function isGranted(SourceInterface $source, string $layer, string $right): bool
|
||||
|
@@ -11,8 +11,10 @@ interface GrantedInterface
|
||||
{
|
||||
/**
|
||||
* Returns true if the source is granted access to the layer with the requested right.
|
||||
*
|
||||
* @param SourceInterface $source
|
||||
* @param string $right
|
||||
* @param string $right
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isGranted(SourceInterface $source, string $layer, string $right): bool;
|
||||
|
Reference in New Issue
Block a user