master
xantxo 3 years ago
parent 57529e871e
commit fbc49281d1

@ -0,0 +1,50 @@
<?php
namespace App\Component\Customer\Domain;
#[ORM\Entity, ORM\Table(name:"customers")]
class Customer
{
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type:Types::INTEGER)]
private int $id;
#[ORM\OneToOne(mappedBy:"user", targetEntity: User::class)]
#[ORM\JoinTable(name:"users")]
#[ORM\JoinColumn(name: "user_id", referencedColumnName: "id")]
#[ORM\InverseJoinColumn(name: "id", referencedColumnName: "user_id")]
protected User $user;
#[ORM\Column(type:Types::STRING, length:255)]
private string $lastname;
#[ORM\Column(type:Types::STRING, length:255)]
private string $firstname;
#[ORM\Column(type:Types::STRING, length:10)]
private string $phoneNumber;
#[ORM\Column(type:Types::STRING, length:3)]
private string $callSign;
#[ORM\Column(type:Types::String, length:255)]
private string $email;
#[ORM\Column(type:Types::String, length:255)]
private string $adresse;
#[ORM\Column(type:Types::String, length:150)]
private string $country;
#[ORM\Column(type:Types::String, length:25)]
private string $postcode;
#[ORM\Column(type:Types::String, length:100)]
private string $city;
#[ORM\Column]
public \DateTime $created;
#[ORM\Column]
public \DateTime $updated;
}

@ -1 +1,9 @@
<?php <?php
namespace App\Component\Customer\Domain;
interface CustomerDataMapper
{
}

@ -1 +1,9 @@
<?php <?php
namespace App\Component\Customer\Domain;
interface CustomerRepository
{
public function findById(int $id): Customer;
public function findAll(): array;
}

@ -41,8 +41,6 @@ class User
public function __construct() public function __construct()
{ {
$this->created = new \DateTime();
$this->updated = new \DateTime();
} }
/** /**

@ -2,6 +2,7 @@
namespace App\Controller; namespace App\Controller;
use App\Component\Role\Infrastructure\RoleDatabaseAdapter;
use App\Component\User\Infrastructure\UserDatabaseAdapter; use App\Component\User\Infrastructure\UserDatabaseAdapter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -20,7 +21,7 @@ class TestController extends AbstractController
{ {
$user = $DoctrineUser->findById(1); $user = $DoctrineUser->findById(1);
return new Response( return new Response(
$user->getId(). " " .$user->getLastname(), $user->getId(). " " .$user->getName(),
Response::HTTP_OK, Response::HTTP_OK,
['content-type' => 'text/html'] ['content-type' => 'text/html']
); );

Loading…
Cancel
Save