chore: removes unused code
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\User\Framework\Pipeline\GettingStarted\AddPreferencesToDatabase;
|
||||
use App\User\Framework\Pipeline\GettingStarted\GettingStartedInput;
|
||||
use App\User\Framework\Pipeline\GettingStarted\MigrateDatabase;
|
||||
use App\User\Framework\Repository\PreferencesRepository;
|
||||
use League\Pipeline\Pipeline;
|
||||
use Psr\Log\LoggerInterface;
|
||||
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\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'provision',
|
||||
description: 'Provision the application for a fresh install. This command migrate the database the latest version and seed it with some required data. This command will do nothing if the app is already provisioned.',
|
||||
)]
|
||||
class ProvisionCommand extends Command
|
||||
{
|
||||
private PreferencesRepository $preferencesRepository;
|
||||
private LoggerInterface $logger;
|
||||
public function __construct(
|
||||
PreferencesRepository $preferencesRepository,
|
||||
LoggerInterface $logger,
|
||||
\Symfony\Component\HttpKernel\KernelInterface $kernel
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->preferencesRepository = $preferencesRepository;
|
||||
$this->logger = $logger;
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$pipelineInput = new GettingStartedInput(
|
||||
kernel: $this->kernel,
|
||||
preferenceRepository: $this->preferencesRepository,
|
||||
logger: $this->logger,
|
||||
);
|
||||
|
||||
$pipeline = (new Pipeline)
|
||||
->pipe(new MigrateDatabase)
|
||||
->pipe(new AddPreferencesToDatabase);
|
||||
|
||||
$pipeline->process($pipelineInput);
|
||||
|
||||
$io->success('You have a new command! Now make it your own! Pass --help to see your options.');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Framework\Pipeline\GettingStarted;
|
||||
|
||||
use App\User\Framework\Repository\PreferencesRepository;
|
||||
use League\Pipeline\StageInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
class AddPreferencesToDatabase implements StageInterface
|
||||
{
|
||||
/** @var GettingStartedInput $input */
|
||||
public function __invoke($input)
|
||||
{
|
||||
if ($input->preferenceRepository->count() > 0) {
|
||||
$input->logger->info('[AddPreferencesToDatabase] > Preferences already exist, skipping...');
|
||||
return $input;
|
||||
}
|
||||
|
||||
$app = new Application($input->kernel);
|
||||
$app->setAutoExit(false);
|
||||
|
||||
$commandInput = new ArrayInput([
|
||||
'command' => 'doctrine:fixtures:load',
|
||||
'--no-interaction',
|
||||
]);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$app->run($commandInput, $output);
|
||||
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Framework\Pipeline\GettingStarted;
|
||||
|
||||
use App\User\Framework\Repository\PreferencesRepository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
class GettingStartedInput
|
||||
{
|
||||
public function __construct(
|
||||
public readonly KernelInterface $kernel,
|
||||
public readonly PreferencesRepository $preferenceRepository,
|
||||
public readonly LoggerInterface $logger
|
||||
) {}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Framework\Pipeline\GettingStarted;
|
||||
|
||||
use League\Pipeline\StageInterface;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
|
||||
class MigrateDatabase implements StageInterface
|
||||
{
|
||||
/** @var GettingStartedInput $input */
|
||||
public function __invoke($input)
|
||||
{
|
||||
$app = new Application($input->kernel);
|
||||
$app->setAutoExit(false);
|
||||
|
||||
$commandInput = new ArrayInput([
|
||||
'command' => 'doctrine:migrations:migrate',
|
||||
'--no-interaction' => true,
|
||||
]);
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$app->run($commandInput, $output);
|
||||
|
||||
$input->logger->info('[MigrateDatabase] > Migrating database...', ['output' => $output->fetch()]);
|
||||
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user