mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized right and reciever logic
This commit is contained in:
parent
8f983659bc
commit
f634555ed5
@ -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;
|
||||
|
@ -22,5 +22,7 @@ class RecieverTest extends TestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(Collection::class, $this->reciever->getMembers());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->reciever->getRight();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use App\DBAL\Types\RightType;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Meta\Right;
|
||||
use App\Entity\Meta\Law;
|
||||
use App\Entity\Meta\RecieverInterface;
|
||||
|
||||
/**
|
||||
* @todo Implement reciever test
|
||||
@ -27,8 +28,10 @@ class RightTest extends TestCase
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertInstanceOf(RecieverInterface::class, $this->right->getReciever());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->assertNull($this->right->getLaw());
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->assertNull($this->right->getType());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user