Optimized ORM Draft

This commit is contained in:
Kevin Frantz 2018-09-06 14:34:43 +02:00
parent f9e44deac4
commit bccafb4740
6 changed files with 68 additions and 19 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
trait ChildsAttribut {
/**
* @var ArrayCollection
*/
protected $childs;
public function getChilds(): ArrayCollection
{
return $this->getChilds();
}
public function setChilds(ArrayCollection $childs): void
{
$this->childs = $childs;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
interface ChildsAttributeInterface
{
public function setChilds(ArrayCollection $childs):void;
public function getChilds():ArrayCollection;
}

View File

@ -12,7 +12,7 @@ trait NodeAttribut{
/**
* @var NodeInterface
* @ORM\OneToOne(targetEntity="Node")
* @ORM\JoinColumn(name="source", referencedColumnName="id")
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
*/
protected $node;

View File

@ -2,7 +2,6 @@
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface;
/**
*
@ -10,9 +9,9 @@ use App\Entity\NodeInterface;
*
*/
trait ParentAttribut {
/**
*
* @var ArrayCollection|NodeInterface[]
* @var ArrayCollection
*/
protected $parents;

View File

@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Attribut\IdAttribut;
use App\Entity\Attribut\SourceAttribut;
use App\Entity\Attribut\ParentAttribut;
use App\Entity\Attribut\ChildsAttribut;
/**
*
@ -15,18 +16,28 @@ use App\Entity\Attribut\ParentAttribut;
*/
class Node implements NodeInterface
{
use IdAttribut,SourceAttribut, ParentAttribut;
use IdAttribut,SourceAttribut, ParentAttribut, ChildsAttribut;
/**
*
* 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|Node[]
*/
protected $parents;
/**
* Many Nodes have many childs
* @ORM\ManyToMany(targetEntity="Node")
* @ORM\JoinTable(name="nodes_childs",
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
* )
* @var ArrayCollection|Node[]
*/
protected $childs;
public function getChilds(): ArrayCollection
{}
public function setChilds(ArrayCollection $childs): void
{}
}

View File

@ -1,20 +1,16 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Attribut\SourceAttributInterface;
use App\Entity\Attribut\IdAttributInterface;
use App\Entity\Attribut\ParentsAttributInterface;
use App\Entity\Attribut\ChildsAttributeInterface;
/**
*
* @author kevinfrantz
*
*/
interface NodeInterface extends SourceAttributInterface, IdAttributInterface,ParentsAttributInterface
{
public function setChilds(ArrayCollection $childs):void;
public function getChilds():ArrayCollection;
}
interface NodeInterface extends SourceAttributInterface, IdAttributInterface,ParentsAttributInterface,ChildsAttributeInterface
{}