mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Implemented Reciever
This commit is contained in:
parent
8a5efb2e1f
commit
043c8d45b7
@ -17,6 +17,7 @@ doctrine:
|
||||
url: '%env(resolve:DATABASE_URL)%'
|
||||
types:
|
||||
RightType: App\DBAL\Types\RightType
|
||||
RecieverType: App\DBAL\Types\RecieverType
|
||||
orm:
|
||||
auto_generate_proxy_classes: '%kernel.debug%'
|
||||
naming_strategy: doctrine.orm.naming_strategy.underscore
|
||||
|
23
application/src/DBAL/Types/RecieverType.php
Normal file
23
application/src/DBAL/Types/RecieverType.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?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';
|
||||
|
||||
protected static $choices = [
|
||||
self::NODE => 'node',
|
||||
self::PARENTS => 'parents',
|
||||
self::CHILDREN => 'children',
|
||||
];
|
||||
}
|
@ -3,11 +3,12 @@
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\PermissionInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait PermissionAttribut
|
||||
trait PermissionsAttribut
|
||||
{
|
||||
/**
|
||||
* @var ArrayCollection
|
||||
@ -23,4 +24,9 @@ trait PermissionAttribut
|
||||
{
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
public function addPermission(PermissionInterface $permission): void
|
||||
{
|
||||
$this->permissions->add($permission);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\PermissionInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -12,4 +13,6 @@ interface PermissionsAttributInterface
|
||||
public function setPermissions(ArrayCollection $permissions): void;
|
||||
|
||||
public function getPermissions(): ArrayCollection;
|
||||
|
||||
public function addPermission(PermissionInterface $permission): void;
|
||||
}
|
||||
|
24
application/src/Entity/Attribut/RecieverAttribut.php
Normal file
24
application/src/Entity/Attribut/RecieverAttribut.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RecieverAttribut
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
public function setReciever(string $type): void
|
||||
{
|
||||
$this->reciever = $type;
|
||||
}
|
||||
|
||||
public function getReciever(): string
|
||||
{
|
||||
return $this->reciever;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RecieverAttributInterface
|
||||
{
|
||||
public function setReciever(string $type): void;
|
||||
|
||||
public function getReciever(): string;
|
||||
}
|
@ -42,5 +42,19 @@ class Node extends AbstractEntity implements NodeInterface
|
||||
{
|
||||
$this->law = new Law();
|
||||
$this->law->setNode($this);
|
||||
$this->initPermissions();
|
||||
}
|
||||
|
||||
private function initPermissions(): void
|
||||
{
|
||||
/*
|
||||
* @var RightInterface
|
||||
*/
|
||||
foreach ($this->law->getRights()->toArray() as $right) {
|
||||
$permission = new Permission();
|
||||
$permission->setNode($this);
|
||||
$permission->setRight($right);
|
||||
$right->addPermission($permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ use App\Entity\Attribut\BlacklistAttribut;
|
||||
use App\Entity\Attribut\WhitelistAttribut;
|
||||
use App\Entity\Attribut\NodeAttribut;
|
||||
use App\Entity\Attribut\RightAttribut;
|
||||
use App\Entity\Attribut\RecieverAttribut;
|
||||
use App\DBAL\Types\RecieverType;
|
||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -15,7 +18,15 @@ use App\Entity\Attribut\RightAttribut;
|
||||
*/
|
||||
class Permission extends AbstractEntity implements PermissionInterface
|
||||
{
|
||||
use BlacklistAttribut,WhitelistAttribut,NodeAttribut,RightAttribut;
|
||||
use NodeAttribut,RightAttribut,WhitelistAttribut,BlacklistAttribut,RecieverAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="reciever", type="RecieverType", nullable=false)
|
||||
* @DoctrineAssert\Enum(entity="App\DBAL\Types\RecieverType")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
@ -46,4 +57,10 @@ class Permission extends AbstractEntity implements PermissionInterface
|
||||
* @var RightInterface
|
||||
*/
|
||||
protected $right;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->blacklist = false;
|
||||
$this->whitelist = false;
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,11 @@ use App\Entity\Attribut\BlacklistAttributInterface;
|
||||
use App\Entity\Attribut\WhitelistAttributInterface;
|
||||
use App\Entity\Attribut\NodeAttributInterface;
|
||||
use App\Entity\Attribut\RightAttributInterface;
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface, NodeAttributInterface, RightAttributInterface
|
||||
interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface, NodeAttributInterface, RightAttributInterface, RecieverAttributInterface
|
||||
{
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use App\DBAL\Types\RightType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||
use App\Entity\Attribut\LawAttribut;
|
||||
use App\Entity\Attribut\PermissionAttribut;
|
||||
use App\Entity\Attribut\PermissionsAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -17,7 +17,7 @@ use App\Entity\Attribut\PermissionAttribut;
|
||||
*/
|
||||
class Right extends AbstractEntity implements RightInterface
|
||||
{
|
||||
use TypeAttribut,LawAttribut,PermissionAttribut;
|
||||
use TypeAttribut,LawAttribut,PermissionsAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Law")
|
||||
|
Loading…
Reference in New Issue
Block a user