Optimized ORM-Structure

This commit is contained in:
Kevin Frantz
2018-09-06 15:14:33 +02:00
parent 261b704017
commit a857f515d3
7 changed files with 95 additions and 52 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
@@ -9,8 +11,14 @@ use Doctrine\Common\Collections\ArrayCollection;
*/
trait ChildsAttribut {
/**
* @var ArrayCollection
/**
* 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|NodeInterface[]
*/
protected $childs;

View File

@@ -2,6 +2,7 @@
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface;
/**
*
@@ -9,17 +10,24 @@ use Doctrine\Common\Collections\ArrayCollection;
*
*/
trait ParentAttribut {
/**
* @var ArrayCollection
* 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|NodeInterface[]
*/
protected $parents;
public function getParents(): ArrayCollection
{
return $this->parents;
}
public function setParents(ArrayCollection $parents): void
{
$this->parents = $parents;

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Entity\Attribut;
/**
*
* @author kevinfrantz
*
*/
trait PasswordAttribut {
/**
* @ORM\Column(type="string", length=64)
*/
protected $password;
public function getPassword():string
{
return $this->password;
}
public function setPassword(string $password):void{
$this->password = $password;
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Entity\Attribut;
/**
* This trait doesn't need an own interface because it's covered by symfony
* @author kevinfrantz
*
*/
trait UsernameAttribut{
/**
* @ORM\Column(type="string", length=25, unique=true)
*/
protected $username;
public function getUsername():string
{
return $this->username;
}
public function setUsernames(string $username):void{
$this->username = $username;
}
}