Configuration and Command
This commit is contained in:
@ -4,8 +4,8 @@ use Psr\Container\ContainerInterface;
|
||||
return [
|
||||
ProVM\Generator\Migration::class => function(ContainerInterface $container) {
|
||||
return new ProVM\Generator\Migration(
|
||||
$container->get(ProVM\Concept\Database\Connection::class),
|
||||
$container->get(ProVM\Concept\Database::class),
|
||||
$container->get(ProVM\Concept\Database\Connection::class),
|
||||
$container->get(ProVM\Concept\Database\Query\Builder::class),
|
||||
$container->get(ProVM\Repository\Table::class),
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
@ -14,5 +14,19 @@ return [
|
||||
$container->get('paths.migrations'),
|
||||
$container->get('skips')
|
||||
);
|
||||
},
|
||||
ProVM\Generator\Seed::class => function(ContainerInterface $container) {
|
||||
return new ProVM\Generator\Seed(
|
||||
$container->get(ProVM\Concept\Database::class),
|
||||
$container->get(ProVM\Concept\Database\Connection::class),
|
||||
$container->get(ProVM\Concept\Database\Query\Builder::class),
|
||||
$container->get(ProVM\Repository\Table::class),
|
||||
$container->get(ProVM\Repository\Data::class),
|
||||
$container->get(Psr\Log\LoggerInterface::class),
|
||||
$container->get('DB_DATABASE'),
|
||||
$container->get('paths.seeds'),
|
||||
new DateTimeImmutable($container->get('start_date')),
|
||||
$container->get('skips')
|
||||
);
|
||||
}
|
||||
];
|
34
app/src/Command/GenerateSeeds.php
Normal file
34
app/src/Command/GenerateSeeds.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace ProVM\Command;
|
||||
|
||||
use Symfony\Component\Console;
|
||||
use ProVM\Generator;
|
||||
|
||||
#[Console\Attribute\AsCommand(
|
||||
name: 'generate:seeds'
|
||||
)]
|
||||
class GenerateSeeds extends Console\Command\Command
|
||||
{
|
||||
public function __construct(protected Generator\Seed $seedGenerator, ?string $name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
parent::configure();
|
||||
$this->addOption('dry-run', 'd', Console\Input\InputOption::VALUE_OPTIONAL, default: false);
|
||||
}
|
||||
|
||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
|
||||
{
|
||||
$io = new Console\Style\SymfonyStyle($input, $output);
|
||||
$io->title('Generate Seeds');
|
||||
|
||||
$dryRun = $input->getOption('dry-run');
|
||||
|
||||
$this->seedGenerator->generate($io, $dryRun);
|
||||
|
||||
return Console\Command\Command::SUCCESS;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user