Correction norme

master
Xantxo COQUILLARD 3 years ago
parent c8c3b42b0e
commit 706166fa26

@ -2,31 +2,28 @@
namespace App\Composant\User\Domain;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="users")
*/
#[ORM\Entity, ORM\Table(name:"users")]
class User
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type:Types::INTEGER)]
private int $id;
/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(type:Types::STRING, length:255)]
private string $lastname;
//finir le reste xD
private string $firstname;
private int $roleId;
private float $kwhPrice, $hourlyCost;
private float $kwhPrice;
private float $hourlyCost;
public function __construct()
{

@ -4,6 +4,5 @@ namespace App\Composant\User\Domain;
interface UserDataMapper
{
public function findById(int $id): User;
public function findAll(): array;
}

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

@ -4,11 +4,12 @@ namespace App\Composant\User\Infrastructure;
use App\Composant\User\Domain\User;
use App\Composant\User\Domain\UserDataMapper;
use App\Composant\User\Domain\UserRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Exception;
class DoctrineUser extends ServiceEntityRepository implements UserDataMapper
class UserDatabaseAdapter extends ServiceEntityRepository implements UserDataMapper, UserRepository
{
public function __construct(ManagerRegistry $registry)

@ -2,27 +2,27 @@
namespace App\Controller;
use App\Composant\User\Infrastructure\DoctrineUser;
use App\Composant\User\Infrastructure\UserDatabaseAdapter;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use function dd;
class test extends AbstractController
class TestController extends AbstractController
{
public function __construct()
{
}
#[Route('/foo', name: 'contact')]
#[Route('/foo')]
public function index(ManagerRegistry $registry): Response
{
$DoctrineUser = new DoctrineUser($registry);
$User = $DoctrineUser->findById(1);
dd($User);
$DoctrineUser = new UserDatabaseAdapter($registry);
$user = $DoctrineUser->findById(1);
return new Response(
"",
$user->getId(). " " .$user->getLastname(),
Response::HTTP_OK,
['content-type' => 'text/html']
);
Loading…
Cancel
Save