79 lines
2.1 KiB
PHP
Raw Normal View History

2018-09-05 15:46:14 +02:00
<?php
2018-09-12 23:25:22 +03:00
2018-10-28 15:25:32 +01:00
namespace App\Entity\Meta;
2018-09-05 15:46:14 +02:00
2018-09-06 14:03:08 +02:00
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\IdAttribut;
use App\Entity\Attribut\SourceAttribut;
2018-09-13 22:35:32 +02:00
use App\Entity\Attribut\ParentsAttribut;
2018-09-06 14:34:43 +02:00
use App\Entity\Attribut\ChildsAttribut;
2018-09-13 14:39:03 +02:00
use App\Entity\Attribut\LawAttribut;
2018-09-21 19:43:48 +02:00
use Doctrine\Common\Collections\ArrayCollection;
2018-10-03 16:14:15 +02:00
use App\Entity\Source\SourceInterface;
2018-10-03 18:20:53 +02:00
use Doctrine\Common\Collections\Collection;
2018-09-05 15:46:14 +02:00
/**
2018-10-29 19:01:00 +01:00
* This class represents a relation.
2018-11-04 13:05:35 +01:00
* A relationship represents the creators and the created objects.
2018-10-29 19:01:00 +01:00
*
2018-09-05 15:46:14 +02:00
* @author kevinfrantz
2018-10-29 19:01:00 +01:00
*
2018-10-25 22:03:10 +02:00
* @todo rename and refactor this class
2018-10-28 15:41:43 +01:00
* @ORM\Table(name="meta_relation")
2018-09-20 16:03:00 +02:00
* @ORM\Entity()
2018-09-05 15:46:14 +02:00
*/
2018-11-20 22:04:29 +01:00
class Relation extends AbstractMeta implements RelationInterface
2018-09-05 15:46:14 +02:00
{
2018-09-06 15:14:33 +02:00
use IdAttribut,
2018-09-12 23:25:22 +03:00
SourceAttribut,
2018-09-13 22:35:32 +02:00
ParentsAttribut,
2018-09-13 14:39:03 +02:00
LawAttribut,
2018-09-06 15:14:33 +02:00
ChildsAttribut;
2018-10-29 19:01:00 +01:00
2018-10-03 18:20:53 +02:00
/**
2018-10-29 19:01:00 +01:00
* Parents represent the creators of the relation.
*
2018-10-31 21:53:30 +01:00
* @ORM\ManyToMany(targetEntity="Relation",mappedBy="childs")
2018-10-31 22:12:00 +01:00
*
2018-10-27 14:56:26 +02:00
* @var Collection|RelationInterface[]
2018-10-03 18:20:53 +02:00
*/
protected $parents;
2018-10-29 19:01:00 +01:00
2018-10-03 18:20:53 +02:00
/**
2018-10-29 19:01:00 +01:00
* Childs represent the by the object produced relations.
2018-10-31 22:12:00 +01:00
*
2018-10-31 22:02:01 +01:00
* @ORM\ManyToMany(targetEntity="Relation",inversedBy="parents")
2018-10-28 15:41:43 +01:00
* @ORM\JoinTable(name="meta_relation_childs",
2018-10-27 14:56:26 +02:00
* joinColumns={@ORM\JoinColumn(name="relation_id", referencedColumnName="id")},
2018-10-31 21:53:30 +01:00
* inverseJoinColumns={@ORM\JoinColumn(name="child_id", referencedColumnName="id")}
2018-10-03 18:20:53 +02:00
* )
*
2018-10-27 14:56:26 +02:00
* @var Collection|RelationInterface[]
2018-10-03 18:20:53 +02:00
*/
protected $childs;
2018-09-13 16:51:58 +02:00
2018-09-13 15:55:48 +02:00
/**
2018-10-03 16:48:16 +02:00
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="source_id", referencedColumnName="id",onDelete="CASCADE")
2018-09-13 16:51:58 +02:00
*
2018-09-13 15:55:48 +02:00
* @var SourceInterface
*/
protected $source;
2018-09-13 16:51:58 +02:00
2018-09-13 15:55:48 +02:00
/**
* @ORM\OneToOne(targetEntity="Law",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
2018-09-13 16:51:58 +02:00
*
2018-09-13 15:55:48 +02:00
* @var LawInterface
*/
protected $law;
2018-09-13 16:51:58 +02:00
public function __construct()
{
parent::__construct();
2018-09-13 14:39:03 +02:00
$this->law = new Law();
2018-09-21 19:43:48 +02:00
$this->parents = new ArrayCollection();
$this->childs = new ArrayCollection();
2018-09-13 14:39:03 +02:00
}
2018-09-05 15:46:14 +02:00
}