Refactored relation and node draft

This commit is contained in:
Kevin Frantz
2018-10-27 14:56:26 +02:00
parent 7734f57c63
commit a95ff0497e
24 changed files with 260 additions and 160 deletions

View File

@@ -2,12 +2,14 @@
namespace App\Entity\Source;
use App\Entity\Attribut\NodeAttribut;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Exclude;
use App\Entity\NodeInterface;
use App\Entity\AbstractEntity;
use App\Entity\Node;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\Attribut\GroupSourcesAttribut;
use App\Entity\RelationInterface;
use App\Entity\Attribut\RelationAttribut;
use App\Entity\Relation;
/**
* @author kevinfrantz
@@ -17,24 +19,30 @@ use App\Entity\Node;
* @ORM\Table(name="source")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"user" = "UserSource","name" = "NameSource","collection" = "SourcesSource"})
* @ORM\DiscriminatorMap({"user" = "UserSource","name" = "NameSource","group" = "GroupSource"})
*/
abstract class AbstractSource extends AbstractEntity implements SourceInterface
{
use NodeAttribut;
use RelationAttribut,GroupSourcesAttribut;
/**
* @var NodeInterface
* @ORM\OneToOne(targetEntity="App\Entity\Node",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
* @var RelationInterface
* @ORM\OneToOne(targetEntity="App\Entity\Relation",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="relation_id", referencedColumnName="id")
* @Exclude
*/
protected $node;
protected $relation;
/**
* @var Collection|GroupSource[]
* @ORM\ManyToMany(targetEntity="GroupSource")
*/
protected $groups;
public function __construct()
{
parent::__construct();
$this->node = new Node();
$this->node->setSource($this);
$this->relation = new Relation();
$this->relation->setSource($this);
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Entity\Source\Attribut;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\GroupSourceInterface;
/**
*
* @author kevinfrantz
*
*/
trait GroupSourcesAttribut
{
/**
*
* @var Collection|GroupSourceInterface[]
*/
protected $groups;
/**
*
* @return Collection|GroupSourceInterface[]
*/
public function getGroupSources():Collection{
return $this->groups;
}
/**
*
* @param Collection|GroupSourceInterface[] $groups
*/
public function setGroupSources(Collection $groups):void{
$this->groups = $groups;
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Entity\Source\Attribut;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\GroupSourceInterface;
/**
*
* @author kevinfrantz
*
*/
interface GroupSourcesAttributInterface
{
/**
* @param Collection|GroupSourceInterface[] $groups
*/
public function setGroupSources(Collection $groups):void;
/**
* @return Collection|GroupSourceInterface[]
*/
public function getGroupSources():Collection;
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Entity\Source\Attribut;
use Doctrine\Common\Collections\Collection;
/**
*
* @author kevinfrantz
*
*/
trait MembersAttribut
{
/**
*
* @var Collection
*/
protected $members;
public function getMembers(): Collection
{
return $this->members;
}
public function setMembers(Collection $members): void
{
$this->members = $members;
}
}

View File

@@ -9,17 +9,16 @@ use Doctrine\Common\Collections\Collection;
* @author kevinfrantz
*
*/
interface SourcesAttributInterface
interface MembersAttributInterface
{
/**
* @param Collection $members
*/
public function setSources(Collection $sources): void;
public function setMembers(Collection $members): void;
/**
* @return Collection
*/
public function getSources(): Collection;
}
public function getMembers(): Collection;
}

View File

@@ -1,30 +0,0 @@
<?php
namespace App\Entity\Source\Attribut;
use Doctrine\Common\Collections\Collection;
/**
*
* @author kevinfrantz
*
*/
trait SourcesAttribut
{
/**
*
* @var Collection
*/
protected $sources;
public function getSources(): Collection
{
return $this->sources;
}
public function setSources(Collection $sources): void
{
$this->sources = $sources;
}
}

View File

@@ -3,8 +3,8 @@ namespace App\Entity\Source;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use App\Entity\Attribut\SourceAttribut;
use App\Entity\Source\Attribut\SourcesAttribut;
use App\Entity\Source\Attribut\MembersAttributInterface;
use App\Entity\Source\Attribut\MembersAttribut;
/**
*
@@ -12,15 +12,15 @@ use App\Entity\Source\Attribut\SourcesAttribut;
* @ORM\Table(name="source_sources")
* @ORM\Entity
*/
class SourcesSource extends AbstractSource implements SourcesSourceInterface
class GroupSource extends AbstractSource implements MembersAttributInterface
{
use SourcesAttribut;
use MembersAttribut;
/**
*
* @var Collection
* @ORM\ManyToMany(targetEntity="AbstractSource")
*/
protected $sources;
protected $members;
}

View File

@@ -1,15 +1,14 @@
<?php
namespace App\Entity\Source;
use App\Entity\Source\Attribut\SourcesAttributInterface;
use App\Entity\Source\Attribut\MembersAttributInterface;
/**
* @author kevinfrantz
* @todo Map the not jet mapped functions!
*
*/
interface SourcesSourceInterface extends SourcesAttributInterface
interface GroupSourceInterface extends MembersAttributInterface
{
}

View File

@@ -1,14 +1,14 @@
<?php
namespace App\Entity\Source;
use App\Entity\Attribut\NodeAttributInterface;
use App\Entity\Attribut\IdAttributInterface;
use App\Entity\EntityInterface;
use App\Entity\Source\Attribut\GroupSourcesAttributInterface;
/**
*
* @author kevinfrantz
*/
interface SourceInterface extends IdAttributInterface, NodeAttributInterface, EntityInterface
interface SourceInterface extends IdAttributInterface, EntityInterface, GroupSourcesAttributInterface
{
}