2018-11-20 22:04:29 +01:00

79 lines
2.1 KiB
PHP

<?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")
*
* @var LawInterface
*/
protected $law;
public function __construct()
{
parent::__construct();
$this->law = new Law();
$this->parents = new ArrayCollection();
$this->childs = new ArrayCollection();
}
}