mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Refactored reciever
This commit is contained in:
@@ -26,9 +26,9 @@ final class RightChecker implements RightCheckerInterface
|
||||
*/
|
||||
private function getAllSourcesToWhichRightApplies(): Collection
|
||||
{
|
||||
$rightSourceMemberInformation = new SourceMemberInformation($this->right->getSource());
|
||||
$rightSourceMemberInformation = new SourceMemberInformation($this->right->getReciever());
|
||||
$allSourcesToWhichRightApplies = clone $rightSourceMemberInformation->getAllMembers();
|
||||
$allSourcesToWhichRightApplies->add($this->right->getSource());
|
||||
$allSourcesToWhichRightApplies->add($this->right->getReciever());
|
||||
|
||||
return $allSourcesToWhichRightApplies;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -10,16 +10,16 @@ use App\Entity\Meta\RecieverInterface;
|
||||
trait RecieverAttribut
|
||||
{
|
||||
/**
|
||||
* @var RecieverInterface
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
public function setReciever(RecieverInterface $reciever): void
|
||||
public function setReciever(SourceInterface $reciever): void
|
||||
{
|
||||
$this->reciever = $reciever;
|
||||
}
|
||||
|
||||
public function getReciever(): RecieverInterface
|
||||
public function getReciever(): SourceInterface
|
||||
{
|
||||
return $this->reciever;
|
||||
}
|
||||
|
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverAttributInterface
|
||||
{
|
||||
public function setReciever(RecieverInterface $reciever): void;
|
||||
public function setReciever(SourceInterface $reciever): void;
|
||||
|
||||
public function getReciever(): RecieverInterface;
|
||||
public function getReciever(): SourceInterface;
|
||||
}
|
||||
|
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Attribut\RightAttribut;
|
||||
use App\Entity\Attribut\CollectionAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="meta_reciever")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Reciever extends AbstractMeta implements RecieverInterface
|
||||
{
|
||||
use RightAttribut, CollectionAttribut;
|
||||
|
||||
/**
|
||||
* The right which the reciever group belongs to.
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="Right",cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(name="right_id", referencedColumnName="id",onDelete="CASCADE")
|
||||
*
|
||||
* @var RightInterface
|
||||
*/
|
||||
protected $right;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="App\Entity\Source\AbstractSource")
|
||||
* @ORM\JoinTable(name="meta_reciever_members",
|
||||
* joinColumns={@ORM\JoinColumn(name="reciever_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="source_id", referencedColumnName="id")}
|
||||
* )
|
||||
*
|
||||
* @var ArrayCollection | SourceInterface[]
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->collection = new ArrayCollection();
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RightAttributInterface;
|
||||
use App\Entity\Attribut\CollectionAttributInterface;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
}
|
@@ -15,6 +15,7 @@ use App\Entity\Attribut\RecieverAttribut;
|
||||
use App\Entity\Attribut\LayerAttribut;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Attribut\PriorityAttribut;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -25,6 +26,14 @@ class Right extends AbstractMeta implements RightInterface
|
||||
{
|
||||
use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut,PriorityAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(name="source_id", referencedColumnName="id",onDelete="CASCADE")
|
||||
*
|
||||
* @var SourceInterface The requested source to which the law applies
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
@@ -49,10 +58,11 @@ class Right extends AbstractMeta implements RightInterface
|
||||
protected $layer;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="Reciever",cascade={"persist", "remove"})
|
||||
* @todo Test and implement it on an correct way!
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="reciever_id", referencedColumnName="id",onDelete="CASCADE")
|
||||
*
|
||||
* @var RecieverInterface
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
@@ -84,7 +94,5 @@ class Right extends AbstractMeta implements RightInterface
|
||||
parent::__construct();
|
||||
$this->grant = true;
|
||||
$this->priority = 0;
|
||||
$this->reciever = new Reciever();
|
||||
$this->reciever->setRight($this);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user