Optimized Entity draft

This commit is contained in:
Kevin Frantz 2018-09-06 13:52:34 +02:00
parent 74038092e3
commit 3d42526698
13 changed files with 66 additions and 50 deletions

View File

@ -7,6 +7,7 @@ use App\Entity\attribut\NodeAttribut;
/**
*
* @author kevinfrantz
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html
*
*/
abstract class AbstractSource implements SourceInterface

View File

@ -1,5 +1,5 @@
<?php
namespace App\Entity\attribut;
namespace App\Entity\Attribut;
/**
*

View File

@ -1,5 +1,5 @@
<?php
namespace App\Entity\attribut;
namespace App\Entity\Attribut;
/**
*

View File

@ -1,5 +1,5 @@
<?php
namespace App\Entity\attribut;
namespace App\Entity\Attribut;
use App\Entity\NodeInterface;
@ -11,6 +11,8 @@ use App\Entity\NodeInterface;
trait NodeAttribut{
/**
* @var NodeInterface
* @OneToOne(targetEntity="Node")
* @JoinColumn(name="source", referencedColumnName="id")
*/
protected $node;

View File

@ -1,5 +1,5 @@
<?php
namespace App\Entity\attribut;
namespace App\Entity\Attribut;
use App\Entity\NodeInterface;

View File

@ -0,0 +1,29 @@
<?php
namespace Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
trait ParentAttribut {
/**
*
* @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,17 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
interface ParentsAttributInterface
{
public function setParents(ArrayCollection $parents):void;
public function getParents():ArrayCollection;
}

View File

@ -1,5 +1,5 @@
<?php
namespace App\Entity\attribut;
namespace App\Entity\Attribut;
use App\Entity\SourceInterface;

View File

@ -1,5 +1,5 @@
<?php
namespace App\Entity\attribut;
namespace App\Entity\Attribut;
use App\Entity\SourceInterface;

View File

@ -2,7 +2,7 @@
namespace App\Entity;
/**
*
* This class is not a source!
* @author kevinfrantz
*
*/

View File

@ -2,6 +2,9 @@
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\attribut\IdAttribut;
use App\Entity\attribut\SourceAttribut;
use Entity\attribut\ParentAttribut;
/**
*
@ -10,23 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection;
*/
class Node implements NodeInterface
{
/**
*
* @var int
*/
protected $id;
/**
*
* @var SourceInterface
*/
protected $source;
/**
*
* @var ArrayCollection|Node[]
*/
protected $parents;
use IdAttribut,SourceAttribut, ParentAttribut;
/**
*
@ -34,26 +21,10 @@ class Node implements NodeInterface
*/
protected $childs;
public function getParents(): ArrayCollection
{}
public function setParents(ArrayCollection $parents): void
{}
public function getChilds(): ArrayCollection
{}
public function setChilds(ArrayCollection $childs): void
{}
public function getId(): int
{}
public function setSource(SourceInterface $source):void
{}
public function getSource(): SourceInterface
{}
}

View File

@ -2,21 +2,17 @@
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\attribut\SourceAttributInterface;
use App\Entity\Attribut\SourceAttributInterface;
use App\Entity\Attribut\IdAttributInterface;
use App\Entity\Attribut\ParentsAttributInterface;
/**
*
* @author kevinfrantz
*
*/
interface NodeInterface extends SourceAttributInterface
interface NodeInterface extends SourceAttributInterface, IdAttributInterface,ParentsAttributInterface
{
public function getId():int;
public function setParents(ArrayCollection $parents):void;
public function getParents():ArrayCollection;
public function setChilds(ArrayCollection $childs):void;
public function getChilds():ArrayCollection;

View File

@ -8,7 +8,7 @@ use Doctrine\Common\Collections\ArrayCollection;
* @author kevinfrantz
*
*/
class Property extends AbstractSource implements PropertyInterface
class Property implements PropertyInterface
{
/**
*