Adde name source to user

This commit is contained in:
Kevin Frantz 2018-09-14 14:39:47 +02:00
parent bfd5d9416e
commit 1d7aaeb1dd
10 changed files with 82 additions and 30 deletions

View File

@ -1,15 +1,13 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
trait NameAttribut { trait NameAttribut
{
/** /**
*
* @var string * @var string
*/ */
protected $name; protected $name;
@ -24,4 +22,3 @@ trait NameAttribut {
return $this->name; return $this->name;
} }
} }

View File

@ -1,15 +1,13 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface NameAttributInterface interface NameAttributInterface
{ {
public function setName(string $name):void; public function setName(string $name): void;
public function getName():string; public function getName(): string;
} }

View File

@ -0,0 +1,26 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\NameSourceInterface;
/**
* @author kevinfrantz
*/
trait NameSourceAttribut
{
/**
* @var NameSourceInterface
*/
protected $nameSource;
public function setNameSource(NameSourceInterface $nameSource): void
{
$this->nameSource = $nameSource;
}
public function getNameSource(): NameSourceInterface
{
return $this->getNameSource();
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\NameSourceInterface;
/**
* @author kevinfrantz
*/
interface NameSourceAttributInterface
{
public function setNameSource(NameSourceInterface $nameSource): void;
public function getNameSource(): NameSourceInterface;
}

View File

@ -1,11 +1,11 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use App\Entity\Attribut\NameAttribut; use App\Entity\Attribut\NameAttribut;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
* @ORM\Table(name="source_name") * @ORM\Table(name="source_name")
* @ORM\Entity(repositoryClass="App\Repository\NameSourceRepository") * @ORM\Entity(repositoryClass="App\Repository\NameSourceRepository")
@ -16,8 +16,14 @@ class NameSource extends AbstractSource implements NameSourceInterface
/** /**
* @ORM\Column(type="string",length=255) * @ORM\Column(type="string",length=255)
*
* @var string * @var string
*/ */
protected $name; protected $name;
}
public function __construct()
{
parent::__construct();
$this->name = '';
}
}

View File

@ -1,14 +1,12 @@
<?php <?php
namespace App\Entity; namespace App\Entity;
use App\Entity\Attribut\NameAttributInterface; use App\Entity\Attribut\NameAttributInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface NameSourceInterface extends NameAttributInterface interface NameSourceInterface extends NameAttributInterface, SourceInterface
{ {
} }

View File

@ -4,6 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\UserAttribut; use App\Entity\Attribut\UserAttribut;
use App\Entity\Attribut\NameSourceAttribut;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -12,13 +13,27 @@ use App\Entity\Attribut\UserAttribut;
*/ */
class UserSource extends AbstractSource implements UserSourceInterface class UserSource extends AbstractSource implements UserSourceInterface
{ {
use UserAttribut; use UserAttribut,NameSourceAttribut;
/** /**
* @ORM\OneToOne(targetEntity="User") * @ORM\OneToOne(targetEntity="User",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
* *
* @var User * @var User
*/ */
protected $user; protected $user;
/**
* @ORM\OneToOne(targetEntity="NameSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="name_id", referencedColumnName="id")
*
* @var NameSourceInterface
*/
protected $nameSource;
public function __construct()
{
$this->nameSource = new NameSource();
parent::__construct();
}
} }

View File

@ -3,10 +3,11 @@
namespace App\Entity; namespace App\Entity;
use App\Entity\Attribut\UserAttributInterface; use App\Entity\Attribut\UserAttributInterface;
use App\Entity\Attribut\NameSourceAttributInterface;
/** /**
* @author kevinfrantz * @author kevinfrantz
*/ */
interface UserSourceInterface extends SourceInterface, UserAttributInterface interface UserSourceInterface extends SourceInterface, UserAttributInterface, NameSourceAttributInterface
{ {
} }

View File

@ -1,12 +1,10 @@
<?php <?php
namespace App\Form; namespace App\Form;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class NameSourceType class NameSourceType
{ {
} }

View File

@ -1,14 +1,12 @@
<?php <?php
namespace App\Form; namespace App\Form;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
class UserSourceType extends AbstractType class UserSourceType extends AbstractType
{ {
} }