38 lines
883 B
PHP
38 lines
883 B
PHP
<?php
|
|
|
|
namespace App\Component\User\Infrastructure;
|
|
|
|
use App\Component\User\Domain\User;
|
|
use App\Component\User\Domain\UserDataMapper;
|
|
use App\Component\User\Domain\UserRepository;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
use Exception;
|
|
|
|
class UserDatabaseAdapter extends ServiceEntityRepository implements UserDataMapper, UserRepository
|
|
{
|
|
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, User::class);
|
|
}
|
|
|
|
public function findById(int $id): User
|
|
{
|
|
$user = $this->find($id);
|
|
|
|
if (!$user)
|
|
{
|
|
throw new Exception(
|
|
'L\'utilisateur n\'existe pas'
|
|
);
|
|
}
|
|
|
|
return $user;
|
|
}
|
|
|
|
public function findAll(): array
|
|
{
|
|
// TODO: Implement findAll() method.
|
|
}
|
|
} |