diff --git a/src/Module/Core/Application/DTO/UserOutput.php b/src/Module/Core/Application/DTO/UserOutput.php index b1eb8ea..5ebdd22 100644 --- a/src/Module/Core/Application/DTO/UserOutput.php +++ b/src/Module/Core/Application/DTO/UserOutput.php @@ -10,7 +10,7 @@ use DateTimeImmutable; final readonly class UserOutput { public function __construct( - public int $id, + public ?int $id, public string $username, /** @var list */ public array $roles, diff --git a/src/Module/Core/Infrastructure/Console/CreateUserCommand.php b/src/Module/Core/Infrastructure/Console/CreateUserCommand.php index eeb7731..ba647e2 100644 --- a/src/Module/Core/Infrastructure/Console/CreateUserCommand.php +++ b/src/Module/Core/Infrastructure/Console/CreateUserCommand.php @@ -5,7 +5,7 @@ declare(strict_types=1); namespace App\Module\Core\Infrastructure\Console; use App\Module\Core\Domain\Entity\User; -use Doctrine\ORM\EntityManagerInterface; +use App\Module\Core\Domain\Repository\UserRepositoryInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -22,7 +22,7 @@ use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; class CreateUserCommand extends Command { public function __construct( - private readonly EntityManagerInterface $em, + private readonly UserRepositoryInterface $userRepository, private readonly UserPasswordHasherInterface $passwordHasher, ) { parent::__construct(); @@ -52,8 +52,7 @@ class CreateUserCommand extends Command $user->setRoles(['ROLE_ADMIN']); } - $this->em->persist($user); - $this->em->flush(); + $this->userRepository->save($user); $io->success(sprintf('User "%s" created%s.', $username, $input->getOption('admin') ? ' with ROLE_ADMIN' : ''));