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,27 +1,24 @@
<?php
namespace App\Entity\Attribut;
/**
*
* @author kevinfrantz
*
*/
trait NameAttribut {
trait NameAttribut
{
/**
*
* @var string
*/
protected $name;
public function setName(string $name): void
{
$this->name = $name;
}
public function getName(): string
{
return $this->name;
}
}

View File

@ -1,15 +1,13 @@
<?php
namespace App\Entity\Attribut;
/**
*
* @author kevinfrantz
*
*/
interface NameAttributInterface
{
public function setName(string $name):void;
public function getName():string;
}
public function setName(string $name): void;
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
namespace App\Entity;
use App\Entity\Attribut\NameAttribut;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @author kevinfrantz
* @ORM\Table(name="source_name")
* @ORM\Entity(repositoryClass="App\Repository\NameSourceRepository")
@ -13,11 +13,17 @@ use Doctrine\ORM\Mapping as ORM;
class NameSource extends AbstractSource implements NameSourceInterface
{
use NameAttribut;
/**
* @ORM\Column(type="string",length=255)
*
* @var string
*/
protected $name;
}
public function __construct()
{
parent::__construct();
$this->name = '';
}
}

View File

@ -1,14 +1,12 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\NameAttributInterface;
/**
*
* @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 App\Entity\Attribut\UserAttribut;
use App\Entity\Attribut\NameSourceAttribut;
/**
* @author kevinfrantz
@ -12,13 +13,27 @@ use App\Entity\Attribut\UserAttribut;
*/
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")
*
* @var 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;
use App\Entity\Attribut\UserAttributInterface;
use App\Entity\Attribut\NameSourceAttributInterface;
/**
* @author kevinfrantz
*/
interface UserSourceInterface extends SourceInterface, UserAttributInterface
interface UserSourceInterface extends SourceInterface, UserAttributInterface, NameSourceAttributInterface
{
}

View File

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

View File

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