Implemented new draft for meta relations

This commit is contained in:
Kevin Frantz 2018-11-25 22:33:54 +01:00
parent a72b9b0357
commit ba3a246c0c
14 changed files with 183 additions and 95 deletions

View File

@ -3,12 +3,27 @@
namespace App\Entity\Meta;
use App\Entity\AbstractEntity;
use App\Entity\Attribut\SourceAttribut;
use App\Entity\Source\SourceInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @todo Implement source attribut
*
* @author kevinfrantz
*/
abstract class AbstractMeta extends AbstractEntity implements MetaInterface
{
use SourceAttribut;
/**
* @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();

View File

@ -3,6 +3,7 @@
namespace App\Entity\Meta;
use App\Entity\EntityInterface;
use App\Entity\Attribut\SourceAttributInterface;
/**
* Meta entities contain informations which describe sources.
@ -10,6 +11,6 @@ use App\Entity\EntityInterface;
*
* @author kevinfrantz
*/
interface MetaInterface extends EntityInterface
interface MetaInterface extends EntityInterface, SourceAttributInterface
{
}

View File

@ -1,78 +0,0 @@
<?php
namespace App\Entity\Meta;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\IdAttribut;
use App\Entity\Attribut\SourceAttribut;
use App\Entity\Attribut\ParentsAttribut;
use App\Entity\Attribut\ChildsAttribut;
use App\Entity\Attribut\LawAttribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Source\SourceInterface;
use Doctrine\Common\Collections\Collection;
/**
* This class represents a relation.
* A relationship represents the creators and the created objects.
*
* @author kevinfrantz
*
* @todo rename and refactor this class
* @ORM\Table(name="meta_relation")
* @ORM\Entity()
*/
class Relation extends AbstractMeta implements RelationInterface
{
use IdAttribut,
SourceAttribut,
ParentsAttribut,
LawAttribut,
ChildsAttribut;
/**
* Parents represent the creators of the relation.
*
* @ORM\ManyToMany(targetEntity="Relation",mappedBy="childs")
*
* @var Collection|RelationInterface[]
*/
protected $parents;
/**
* Childs represent the by the object produced relations.
*
* @ORM\ManyToMany(targetEntity="Relation",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|RelationInterface[]
*/
protected $childs;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="source_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var SourceInterface
*/
protected $source;
/**
* @ORM\OneToOne(targetEntity="Law",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="law_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var LawInterface
*/
protected $law;
public function __construct()
{
parent::__construct();
$this->law = new Law();
$this->parents = new ArrayCollection();
$this->childs = new ArrayCollection();
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Entity\Meta\Relation;
use App\Entity\Meta\AbstractMeta;
/**
* @author kevinfrantz
*/
abstract class AbstractRelation extends AbstractMeta implements RelationInterface
{
public function __construct()
{
parent::__construct();
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Entity\Meta\Relation\Member;
use App\Entity\Meta\Relation\AbstractRelation;
use App\Entity\Attribut\MembersAttribut;
use App\Entity\Attribut\MembershipsAttribut;
class MemberRelation extends AbstractRelation implements MemberRelationInterface
{
use MembersAttribut,MembershipsAttribut;
}

View File

@ -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
{
}

View File

@ -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();
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Entity\Meta\Relation\Parent;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use App\Entity\Meta\Relation\CreatorRelationInterface;
class CreatorRelation extends AbstractParentRelation
{
/**
* @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;
}

View File

@ -0,0 +1,7 @@
<?php
namespace App\Entity\Meta\Relation;
interface CreatorRelationInterface extends RelationInterface
{
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Entity\Meta\Relation\Parent;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
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;
}

View File

@ -0,0 +1,7 @@
<?php
namespace App\Entity\Meta\Relation\Parent;
interface HeredityRelationInterface extends ParentRelationInterface
{
}

View File

@ -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
{
}

View File

@ -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
{
}

View File

@ -1,16 +0,0 @@
<?php
namespace App\Entity\Meta;
use App\Entity\Attribut\SourceAttributInterface;
use App\Entity\Attribut\IdAttributInterface;
use App\Entity\Attribut\ParentsAttributInterface;
use App\Entity\Attribut\ChildsAttributeInterface;
use App\Entity\Attribut\LawAttributInterface;
/**
* @author kevinfrantz
*/
interface RelationInterface extends SourceAttributInterface, IdAttributInterface, ParentsAttributInterface, ChildsAttributeInterface, LawAttributInterface, MetaInterface
{
}