mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 04:44:19 +01:00
Rector upgrades
This commit is contained in:
@@ -7,9 +7,9 @@ namespace App\Command;
|
|||||||
use App\Repository\SeasonRepository;
|
use App\Repository\SeasonRepository;
|
||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\Console\Attribute\Argument;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
@@ -18,29 +18,19 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
name: 'app:claim-season',
|
name: 'app:claim-season',
|
||||||
description: 'Give a user owner rights on a season',
|
description: 'Give a user owner rights on a season',
|
||||||
)]
|
)]
|
||||||
class ClaimSeasonCommand extends Command
|
readonly class ClaimSeasonCommand
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(private UserRepository $userRepository, private SeasonRepository $seasonRepository, private EntityManagerInterface $entityManager) {}
|
||||||
private readonly UserRepository $userRepository,
|
|
||||||
private readonly SeasonRepository $seasonRepository,
|
|
||||||
private readonly EntityManagerInterface $entityManager)
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function configure(): void
|
public function __invoke(
|
||||||
{
|
#[Argument]
|
||||||
$this
|
string $seasonCode,
|
||||||
->addArgument('email', InputArgument::REQUIRED, 'The email of the user thats claims the season')
|
#[Argument]
|
||||||
->addArgument('season', InputArgument::REQUIRED, 'The season to claim')
|
string $email,
|
||||||
;
|
InputInterface $input,
|
||||||
}
|
OutputInterface $output,
|
||||||
|
): int {
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$email = $input->getArgument('email');
|
|
||||||
$seasonCode = $input->getArgument('season');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$season = $this->seasonRepository->findOneBy(['seasonCode' => $seasonCode]);
|
$season = $this->seasonRepository->findOneBy(['seasonCode' => $seasonCode]);
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace App\Command;
|
namespace App\Command;
|
||||||
|
|
||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
|
use Symfony\Component\Console\Attribute\Argument;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
@@ -16,25 +16,17 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
name: 'app:make-admin',
|
name: 'app:make-admin',
|
||||||
description: 'Give a user the role admin',
|
description: 'Give a user the role admin',
|
||||||
)]
|
)]
|
||||||
class MakeAdminCommand extends Command
|
readonly class MakeAdminCommand
|
||||||
{
|
{
|
||||||
public function __construct(private readonly UserRepository $userRepository)
|
public function __construct(private UserRepository $userRepository) {}
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function configure(): void
|
public function __invoke(
|
||||||
{
|
#[Argument]
|
||||||
$this
|
string $email,
|
||||||
->addArgument('email', InputArgument::REQUIRED, 'The email of the user to make admin')
|
InputInterface $input,
|
||||||
;
|
OutputInterface $output,
|
||||||
}
|
): int {
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$email = $input->getArgument('email');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->userRepository->makeAdmin($email);
|
$this->userRepository->makeAdmin($email);
|
||||||
} catch (\InvalidArgumentException) {
|
} catch (\InvalidArgumentException) {
|
||||||
|
|||||||
Reference in New Issue
Block a user