Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion backend/src/Command/CreateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace App\Command;

use App\Entity\Calendar;
use App\Entity\User;
use App\Enum\UserRole;
use App\Repository\CalendarRepository;
use App\Repository\UserRepository;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
Expand All @@ -23,6 +25,7 @@ class CreateUserCommand extends Command
{
public function __construct(
private readonly UserRepository $userRepository,
private readonly CalendarRepository $calendarRepository,
private readonly ValidatorInterface $validator,
) {
parent::__construct();
Expand Down Expand Up @@ -84,8 +87,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->userRepository->save($user);

$calendar = new Calendar('Personal', $user);
$this->calendarRepository->save($calendar);

$user->setDefaultCalendarId($calendar->getId());
$this->userRepository->save($user);

$io->success(sprintf(
'User "%s" created successfully%s.',
'User "%s" created successfully%s. Default calendar "Personal" created.',
$email,
$isAdmin ? ' with admin role' : '',
));
Expand Down
Loading