mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimized Law draft
This commit is contained in:
parent
69f2beac72
commit
ff7fb57baf
@ -20,4 +20,8 @@ class AbstractEntity
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ abstract class AbstractSource extends AbstractEntity implements SourceInterface
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->node = new Node();
|
||||
$this->node->setSource($this);
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\NodeInterface;
|
||||
namespace Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -11,25 +8,17 @@ use App\Entity\NodeInterface;
|
||||
trait ParentAttribut
|
||||
{
|
||||
/**
|
||||
* Many Nodes have many parents.
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="Node")
|
||||
* @ORM\JoinTable(name="nodes_parents",
|
||||
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
|
||||
* )
|
||||
*
|
||||
* @var ArrayCollection|NodeInterface[]
|
||||
* @var ParentAttributInterface
|
||||
*/
|
||||
protected $parents;
|
||||
protected $parent;
|
||||
|
||||
public function getParents(): ArrayCollection
|
||||
public function setParent(ParentAttributInterface $parent): void
|
||||
{
|
||||
return $this->parents;
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
public function setParents(ArrayCollection $parents): void
|
||||
public function getParent(): ParentAttributInterface
|
||||
{
|
||||
$this->parents = $parents;
|
||||
return $this->parent;
|
||||
}
|
||||
}
|
||||
|
13
application/src/Entity/Attribut/ParentAttributInterface.php
Normal file
13
application/src/Entity/Attribut/ParentAttributInterface.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ParentAttributInterface
|
||||
{
|
||||
public function setParent(ParentAttributInterface $parent): void;
|
||||
|
||||
public function getParent(): ParentAttributInterface;
|
||||
}
|
35
application/src/Entity/Attribut/ParentsAttribut.php
Normal file
35
application/src/Entity/Attribut/ParentsAttribut.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\NodeInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait ParentsAttribut
|
||||
{
|
||||
/**
|
||||
* Many Nodes have many parents.
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="Node")
|
||||
* @ORM\JoinTable(name="nodes_parents",
|
||||
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
|
||||
* )
|
||||
*
|
||||
* @var ArrayCollection|NodeInterface[]
|
||||
*/
|
||||
protected $parents;
|
||||
|
||||
public function getParents(): ArrayCollection
|
||||
{
|
||||
return $this->parents;
|
||||
}
|
||||
|
||||
public function setParents(ArrayCollection $parents): void
|
||||
{
|
||||
$this->parents = $parents;
|
||||
}
|
||||
}
|
26
application/src/Entity/Attribut/PermissionAttribut.php
Normal file
26
application/src/Entity/Attribut/PermissionAttribut.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait PermissionAttribut
|
||||
{
|
||||
/**
|
||||
* @var ArrayCollection
|
||||
*/
|
||||
protected $permissions;
|
||||
|
||||
public function setPermissions(ArrayCollection $permissions): void
|
||||
{
|
||||
$this->permissions = $permissions;
|
||||
}
|
||||
|
||||
public function getPermissions(): ArrayCollection
|
||||
{
|
||||
return $this->permissions;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface PermissionsAttributInterface
|
||||
{
|
||||
public function setPermissions(ArrayCollection $permissions): void;
|
||||
|
||||
public function getPermissions(): ArrayCollection;
|
||||
}
|
26
application/src/Entity/Attribut/RightAttribut.php
Normal file
26
application/src/Entity/Attribut/RightAttribut.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Entity\Attribut;
|
||||
|
||||
use App\Entity\RightInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait RightAttribut
|
||||
{
|
||||
/**
|
||||
* @var RightInterface
|
||||
*/
|
||||
protected $right;
|
||||
|
||||
public function setRight(RightInterface $right): void
|
||||
{
|
||||
$this->right = $right;
|
||||
}
|
||||
|
||||
public function getRight(): RightInterface
|
||||
{
|
||||
return $this->getRight();
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ namespace App\Entity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Attribut\IdAttribut;
|
||||
use App\Entity\Attribut\SourceAttribut;
|
||||
use App\Entity\Attribut\ParentAttribut;
|
||||
use App\Entity\Attribut\ParentsAttribut;
|
||||
use App\Entity\Attribut\ChildsAttribut;
|
||||
use App\Entity\Attribut\LawAttribut;
|
||||
|
||||
@ -18,7 +18,7 @@ class Node extends AbstractEntity implements NodeInterface
|
||||
{
|
||||
use IdAttribut,
|
||||
SourceAttribut,
|
||||
ParentAttribut,
|
||||
ParentsAttribut,
|
||||
LawAttribut,
|
||||
ChildsAttribut;
|
||||
|
||||
|
@ -5,6 +5,8 @@ namespace App\Entity;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Attribut\BlacklistAttribut;
|
||||
use App\Entity\Attribut\WhitelistAttribut;
|
||||
use App\Entity\Attribut\NodeAttribut;
|
||||
use Entity\Attribut\RightAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -13,7 +15,7 @@ use App\Entity\Attribut\WhitelistAttribut;
|
||||
*/
|
||||
class Permission extends AbstractEntity implements PermissionInterface
|
||||
{
|
||||
use BlacklistAttribut,WhitelistAttribut;
|
||||
use BlacklistAttribut,WhitelistAttribut,NodeAttribut,RightAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
@ -28,4 +30,20 @@ class Permission extends AbstractEntity implements PermissionInterface
|
||||
* @var bool
|
||||
*/
|
||||
protected $whitelist;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Node")
|
||||
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
|
||||
*
|
||||
* @var NodeInterface
|
||||
*/
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Right")
|
||||
* @ORM\JoinColumn(name="right_id", referencedColumnName="id")
|
||||
*
|
||||
* @var RightInterface
|
||||
*/
|
||||
protected $right;
|
||||
}
|
||||
|
@ -4,10 +4,12 @@ namespace App\Entity;
|
||||
|
||||
use App\Entity\Attribut\BlacklistAttributInterface;
|
||||
use Entity\Attribut\WhitelistAttributInterface;
|
||||
use App\Entity\Attribut\NodeAttributInterface;
|
||||
use App\Entity\Attribut\RightAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface
|
||||
interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface, NodeAttributInterface, RightAttributInterface
|
||||
{
|
||||
}
|
||||
|
@ -8,6 +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;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -16,10 +17,10 @@ use App\Entity\Attribut\LawAttribut;
|
||||
*/
|
||||
class Right extends AbstractEntity implements RightInterface
|
||||
{
|
||||
use TypeAttribut,LawAttribut;
|
||||
use TypeAttribut,LawAttribut,PermissionAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Law",cascade={"persist", "remove"})
|
||||
* @ORM\ManyToOne(targetEntity="Law")
|
||||
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
|
||||
*
|
||||
* @var LawInterface
|
||||
@ -35,7 +36,7 @@ class Right extends AbstractEntity implements RightInterface
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Right", mappedBy="id", cascade={"persist", "remove"})
|
||||
* @ORM\OneToMany(targetEntity="Permission", mappedBy="id", cascade={"persist", "remove"})
|
||||
*
|
||||
* @var ArrayCollection
|
||||
*/
|
||||
@ -45,7 +46,9 @@ class Right extends AbstractEntity implements RightInterface
|
||||
{
|
||||
}
|
||||
|
||||
public function setPermissions(ArrayCollection $permissions): void
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->permissions = new ArrayCollection();
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,14 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Attribut\TypeAttributInterface;
|
||||
use App\Entity\Attribut\LawAttributInterface;
|
||||
use App\Entity\Attribut\PermissionsAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, PermissionsAttributInterface
|
||||
{
|
||||
public function isGranted(NodeInterface $node): bool;
|
||||
|
||||
public function setPermissions(ArrayCollection $permissions): void;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user