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