Skip to content

Commit

Permalink
Ref #320: remove deprecation linked to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann-BUTSCHER-EIRL committed Jun 10, 2023
1 parent 00e2f87 commit dabb2b4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Command/CreateAdminAccountCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
namespace App\Command;

use App\Service\UserService;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
name: 'app:create-admin-account',
description: 'Creates an admin account.',
)]
class CreateAdminAccountCommand extends Command
{
/**
* @var App\Service\UserService
*/
private $userService;

/**
* @var string Name of the command (used in console)
*/
protected static $defaultName = 'app:create-admin-account';

public function __construct(UserService $userService)
{
$this->userService = $userService;
Expand All @@ -45,16 +46,18 @@ protected function configure()
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Admin account creation started...');
$io = new SymfonyStyle($input, $output);
$io->info('Admin account creation started...');

$this->userService->createFirstAdminAccount(
$input->getArgument('admin-username'),
$input->getArgument('admin-password')
);

$output->writeln('User successfully generated!');
}
$io->success('User successfully generated!');

return Command::SUCCESS;
}
}

0 comments on commit dabb2b4

Please sign in to comment.