mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Refactored reciever group and adapted testing namespaces
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DBAL\Types;
|
||||
|
||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RecieverType extends AbstractEnumType
|
||||
{
|
||||
public const NODE = 'node';
|
||||
|
||||
public const PARENTS = 'parents';
|
||||
|
||||
public const CHILDREN = 'children';
|
||||
|
||||
public const SIBLINGS = 'siblings';
|
||||
|
||||
protected static $choices = [
|
||||
self::NODE => 'node',
|
||||
self::PARENTS => 'parents',
|
||||
self::CHILDREN => 'children',
|
||||
self::SIBLINGS => 'siblings',
|
||||
];
|
||||
}
|
@@ -2,22 +2,24 @@
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RecieverAttribut
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @var RecieverInterface
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
public function setReciever(string $type): void
|
||||
public function setReciever(RecieverInterface $recieverGroup): void
|
||||
{
|
||||
$this->reciever = $type;
|
||||
$this->reciever = $recieverGroup;
|
||||
}
|
||||
|
||||
public function getReciever(): string
|
||||
public function getReciever(): RecieverInterface
|
||||
{
|
||||
return $this->reciever;
|
||||
}
|
||||
|
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverAttributInterface
|
||||
{
|
||||
public function setReciever(string $type): void;
|
||||
public function setReciever(RecieverInterface $recieverGroup): void;
|
||||
|
||||
public function getReciever(): string;
|
||||
public function getReciever(): RecieverInterface;
|
||||
}
|
||||
|
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverGroupInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RecieverGroupAttribut
|
||||
{
|
||||
/**
|
||||
* @var RecieverGroupInterface
|
||||
*/
|
||||
protected $recieverGroup;
|
||||
|
||||
public function setRecieverGroup(RecieverGroupInterface $recieverGroup): void
|
||||
{
|
||||
$this->recieverGroup = $recieverGroup;
|
||||
}
|
||||
|
||||
public function getRecieverGroup(): RecieverGroupInterface
|
||||
{
|
||||
return $this->recieverGroup;
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use App\Entity\Meta\RecieverGroupInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverGroupAttributInterface
|
||||
{
|
||||
public function setRecieverGroup(RecieverGroupInterface $recieverGroup): void;
|
||||
|
||||
public function getRecieverGroup(): RecieverGroupInterface;
|
||||
}
|
34
application/src/Entity/Meta/Reciever.php
Normal file
34
application/src/Entity/Meta/Reciever.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="meta_reciever_group")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class Reciever extends AbstractMeta implements RecieverInterface
|
||||
{
|
||||
use RelationAttribut;
|
||||
|
||||
/**
|
||||
* The node for which the right exists.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Relation")
|
||||
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RelationAttributInterface
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
public function getAllRecievers(): ArrayCollection
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RecieverAttribut;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\DBAL\Types\RecieverType;
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="meta_reciever_group")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
final class RecieverGroup extends AbstractMeta implements RecieverGroupInterface
|
||||
{
|
||||
use RelationAttribut,RecieverAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="reciever", type="RecieverType", nullable=false)
|
||||
* @DoctrineAssert\Enum(entity="App\DBAL\Types\RecieverType")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
/**
|
||||
* The node for which the right exists.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Relation")
|
||||
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RelationAttributInterface
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
public function getAllRecievers(): ArrayCollection
|
||||
{
|
||||
switch ($this->reciever) {
|
||||
case RecieverType::PARENTS:
|
||||
return $this->node->getParents();
|
||||
case RecieverType::NODE:
|
||||
return new ArrayCollection([$this->node]);
|
||||
case RecieverType::CHILDREN:
|
||||
return $this->node->getChilds();
|
||||
}
|
||||
throw new NotImplementedException('Reciever '.$this->reciever.' not implemented.');
|
||||
}
|
||||
}
|
@@ -2,14 +2,13 @@
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverGroupInterface extends RelationAttributInterface, RecieverAttributInterface, MetaInterface
|
||||
interface RecieverInterface extends RelationAttributInterface, MetaInterface
|
||||
{
|
||||
public function getAllRecievers(): ArrayCollection;
|
||||
}
|
@@ -11,7 +11,7 @@ use App\DBAL\Types\RightType;
|
||||
use App\Entity\Attribut\GrantAttribut;
|
||||
use App\Logic\Operation\OperationInterface;
|
||||
use App\Entity\Attribut\ConditionAttribut;
|
||||
use App\Entity\Attribut\RecieverGroupAttribut;
|
||||
use App\Entity\Attribut\RecieverAttribut;
|
||||
use App\Entity\Attribut\LayerAttribut;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
|
||||
@@ -22,7 +22,7 @@ use App\Entity\Attribut\RelationAttribut;
|
||||
*/
|
||||
final class Right extends AbstractMeta implements RightInterface
|
||||
{
|
||||
use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverGroupAttribut,LayerAttribut;
|
||||
use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Law", inversedBy="rights")
|
||||
@@ -44,9 +44,9 @@ final class Right extends AbstractMeta implements RightInterface
|
||||
* @ORM\OneToOne(targetEntity="RecieverGroup",cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(name="reciever_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RecieverGroupInterface
|
||||
* @var RecieverInterface
|
||||
*/
|
||||
protected $recieverGroup;
|
||||
protected $reciever;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean",name="`grant`")
|
||||
|
@@ -4,7 +4,7 @@ namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\TypeAttributInterface;
|
||||
use App\Entity\Attribut\LawAttributInterface;
|
||||
use App\Entity\Attribut\RecieverGroupAttributInterface;
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use App\Entity\Attribut\GrantAttributInterface;
|
||||
use App\Entity\Attribut\ConditionAttributInterface;
|
||||
use App\Entity\Attribut\LayerAttributInterface;
|
||||
@@ -14,6 +14,6 @@ use App\Entity\Attribut\RelationAttributInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverGroupAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, RelationGrantedInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user