mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-29 21:08:13 +02:00
Optimized for SPA
This commit is contained in:
21
application/symfony/src/Entity/Meta/AbstractMeta.php
Normal file
21
application/symfony/src/Entity/Meta/AbstractMeta.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\AbstractEntity;
|
||||
use App\Entity\Attribut\SourceAttribut;
|
||||
|
||||
/**
|
||||
* @todo Implement source attribut
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractMeta extends AbstractEntity implements MetaInterface
|
||||
{
|
||||
use SourceAttribut;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
49
application/symfony/src/Entity/Meta/Law.php
Normal file
49
application/symfony/src/Entity/Meta/Law.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Attribut\RightsAttribute;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Attribut\RelationAttribut;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Attribut\GrantAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="meta_law")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
|
||||
*/
|
||||
class Law extends AbstractMeta implements LawInterface
|
||||
{
|
||||
use RightsAttribute, RelationAttribut, GrantAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean",name="`grant`")
|
||||
*
|
||||
* @var bool the standart grant value
|
||||
*/
|
||||
protected $grant;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(name="source_id", referencedColumnName="id",onDelete="CASCADE")
|
||||
*
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Right", mappedBy="law", cascade={"persist", "remove"})
|
||||
*
|
||||
* @var ArrayCollection | Right[]
|
||||
*/
|
||||
protected $rights;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->rights = new ArrayCollection();
|
||||
$this->grant = false;
|
||||
}
|
||||
}
|
13
application/symfony/src/Entity/Meta/LawInterface.php
Normal file
13
application/symfony/src/Entity/Meta/LawInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\RightsAttributInterface;
|
||||
use App\Entity\Attribut\GrantAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LawInterface extends RightsAttributInterface, MetaInterface, GrantAttributInterface
|
||||
{
|
||||
}
|
16
application/symfony/src/Entity/Meta/MetaInterface.php
Normal file
16
application/symfony/src/Entity/Meta/MetaInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Entity\Attribut\SourceAttributInterface;
|
||||
|
||||
/**
|
||||
* Meta entities contain informations which describe sources.
|
||||
* If you refer from a meta entity to an source be aware to catch infinite loops!
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface MetaInterface extends EntityInterface, SourceAttributInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation;
|
||||
|
||||
use App\Entity\Meta\AbstractMeta;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractRelation extends AbstractMeta implements RelationInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"})
|
||||
* @ORM\JoinColumn(name="source_id", referencedColumnName="id",onDelete="CASCADE")
|
||||
*
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation\Member;
|
||||
|
||||
use App\Entity\Meta\Relation\AbstractRelation;
|
||||
use App\Entity\Attribut\MembersAttribut;
|
||||
use App\Entity\Attribut\MembershipsAttribut;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class MemberRelation extends AbstractRelation implements MemberRelationInterface
|
||||
{
|
||||
use MembersAttribut,MembershipsAttribut;
|
||||
|
||||
/**
|
||||
* Many Sources have many Source Members.
|
||||
*
|
||||
* @var Collection|MemberRelationInterface[]
|
||||
* @ORM\ManyToMany(targetEntity="MemberRelation", inversedBy="memberships",cascade={"persist", "remove"})
|
||||
* @ORM\JoinTable(name="source_members",
|
||||
* joinColumns={@ORM\JoinColumn(name="source_id", referencedColumnName="id",onDelete="CASCADE")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="member_id", referencedColumnName="id",onDelete="CASCADE")}
|
||||
* )
|
||||
*/
|
||||
protected $members;
|
||||
|
||||
/**
|
||||
* @var Collection|MemberRelationInterface[]
|
||||
* @ORM\ManyToMany(targetEntity="MemberRelation",mappedBy="members")
|
||||
*/
|
||||
protected $memberships;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->members = new ArrayCollection();
|
||||
$this->memberships = new ArrayCollection();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation\Member;
|
||||
|
||||
use App\Entity\Meta\Relation\RelationInterface;
|
||||
use App\Entity\Attribut\MembersAttributInterface;
|
||||
use App\Entity\Attribut\MembershipsAttributInterface;
|
||||
|
||||
interface MemberRelationInterface extends RelationInterface, MembersAttributInterface, MembershipsAttributInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation\Parent;
|
||||
|
||||
use App\Entity\Attribut\IdAttribut;
|
||||
use App\Entity\Attribut\ParentsAttribut;
|
||||
use App\Entity\Attribut\ChildsAttribut;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Meta\Relation\AbstractRelation;
|
||||
|
||||
/**
|
||||
* This class represents a relation.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractParentRelation extends AbstractRelation implements ParentRelationInterface
|
||||
{
|
||||
use IdAttribut,
|
||||
ParentsAttribut,
|
||||
ChildsAttribut;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->parents = new ArrayCollection();
|
||||
$this->childs = new ArrayCollection();
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation\Parent;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class CreatorRelation extends AbstractParentRelation implements CreatorRelationInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="CreatorRelation",mappedBy="childs")
|
||||
*
|
||||
* @var Collection|CreatorRelationInterface[]
|
||||
*/
|
||||
protected $parents;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="CreatorRelation",inversedBy="parents")
|
||||
* @ORM\JoinTable(name="meta_relation_childs",
|
||||
* joinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="child_id", referencedColumnName="id")}
|
||||
* )
|
||||
*
|
||||
* @var Collection|CreatorRelationInterface[]
|
||||
*/
|
||||
protected $childs;
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation\Parent;
|
||||
|
||||
use App\Entity\Meta\Relation\RelationInterface;
|
||||
|
||||
interface CreatorRelationInterface extends RelationInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation\Parent;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
class HeredityRelation extends AbstractParentRelation implements HeredityRelationInterface
|
||||
{
|
||||
/**
|
||||
* Parents represent from which inhieres.
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="HeredityRelation",mappedBy="childs")
|
||||
*
|
||||
* @var Collection|HeredityRelationInterface[]
|
||||
*/
|
||||
protected $parents;
|
||||
|
||||
/**
|
||||
* Childs represent the by the object produced relations.
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="HeredityRelation",inversedBy="parents")
|
||||
* @ORM\JoinTable(
|
||||
* joinColumns={
|
||||
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="child_id", referencedColumnName="id")}
|
||||
* )
|
||||
*
|
||||
* @var Collection|HeredityRelationInterface[]
|
||||
*/
|
||||
protected $childs;
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation\Parent;
|
||||
|
||||
interface HeredityRelationInterface extends ParentRelationInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation\Parent;
|
||||
|
||||
use App\Entity\Attribut\ParentsAttributInterface;
|
||||
use App\Entity\Attribut\ChildsAttributeInterface;
|
||||
use App\Entity\Meta\Relation\RelationInterface;
|
||||
|
||||
interface ParentRelationInterface extends RelationInterface, ParentsAttributInterface, ChildsAttributeInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta\Relation;
|
||||
|
||||
use App\Entity\Meta\MetaInterface;
|
||||
|
||||
/**
|
||||
* Describes a relation of a source to another source.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RelationInterface extends MetaInterface
|
||||
{
|
||||
}
|
115
application/symfony/src/Entity/Meta/Right.php
Normal file
115
application/symfony/src/Entity/Meta/Right.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\TypeAttribut;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||
use App\Entity\Attribut\LawAttribut;
|
||||
use App\DBAL\Types\Meta\Right\LayerType;
|
||||
use App\Entity\Attribut\GrantAttribut;
|
||||
use App\Logic\Operation\OperationInterface;
|
||||
use App\Entity\Attribut\ConditionAttribut;
|
||||
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;
|
||||
use App\Exception\NoValidChoiceException;
|
||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="meta_right")
|
||||
* @ORM\Entity(repositoryClass="App\Repository\RightRepository")
|
||||
*/
|
||||
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")
|
||||
*
|
||||
* @var int which priority has the right in a roleset
|
||||
*/
|
||||
protected $priority;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Law", inversedBy="rights")
|
||||
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
|
||||
*
|
||||
* @var LawInterface
|
||||
*/
|
||||
protected $law;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="layer", type="LayerType", nullable=false)
|
||||
* @DoctrineAssert\Enum(entity="App\DBAL\Types\Meta\Right\LayerType")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $layer;
|
||||
|
||||
/**
|
||||
* @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 SourceInterface
|
||||
*/
|
||||
protected $reciever;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean",name="`grant`")
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $grant;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="type", type="CRUDType", nullable=false)
|
||||
* @DoctrineAssert\Enum(entity="App\DBAL\Types\Meta\Right\CRUDType")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Source\Operation\AbstractOperation",cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="operation_id", referencedColumnName="id",nullable=true)
|
||||
*
|
||||
* @var OperationInterface
|
||||
*/
|
||||
protected $condition;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->grant = true;
|
||||
$this->priority = 0;
|
||||
}
|
||||
|
||||
public function setType(string $type): void
|
||||
{
|
||||
if (!array_key_exists($type, CRUDType::getChoices())) {
|
||||
throw new NoValidChoiceException();
|
||||
}
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function setLayer(string $layer): void
|
||||
{
|
||||
if (!array_key_exists($layer, LayerType::getChoices())) {
|
||||
throw new NoValidChoiceException();
|
||||
}
|
||||
$this->layer = $layer;
|
||||
}
|
||||
}
|
19
application/symfony/src/Entity/Meta/RightInterface.php
Normal file
19
application/symfony/src/Entity/Meta/RightInterface.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\TypeAttributInterface;
|
||||
use App\Entity\Attribut\LawAttributInterface;
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use App\Entity\Attribut\GrantAttributInterface;
|
||||
use App\Entity\Attribut\ConditionAttributInterface;
|
||||
use App\Entity\Attribut\LayerAttributInterface;
|
||||
use App\Entity\Attribut\RelationAttributInterface;
|
||||
use App\Entity\Attribut\PriorityAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface, PriorityAttributInterface
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user