1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Shapin\Datagen\Bridge\Symfony\Bundle\Command; |
6
|
|
|
|
7
|
|
|
use Shapin\Datagen\Datagen; |
8
|
|
|
use Symfony\Component\Console\Command\Command; |
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
10
|
|
|
use Symfony\Component\Console\Input\InputOption; |
11
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
12
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
13
|
|
|
|
14
|
|
|
class LoadCommand extends Command |
15
|
|
|
{ |
16
|
|
|
private $datagen; |
17
|
|
|
|
18
|
2 |
|
public function __construct(Datagen $datagen) |
19
|
|
|
{ |
20
|
2 |
|
$this->datagen = $datagen; |
21
|
|
|
|
22
|
2 |
|
parent::__construct(); |
23
|
2 |
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
2 |
|
protected function configure() |
29
|
|
|
{ |
30
|
|
|
$this |
31
|
2 |
|
->setName('shapin:datagen:load') |
32
|
2 |
|
->setDescription('Load the world!') |
33
|
2 |
|
->addOption('groups', 'g', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Which groups should be loaded? (default: all)') |
34
|
2 |
|
->addOption('exclude-groups', 'G', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Which groups should be excluded? (default: none)') |
35
|
2 |
|
->addOption('dbal-schema-only', null, InputOption::VALUE_NONE, '[DBAL] Load only schema.') |
36
|
2 |
|
->addOption('dbal-fixtures-only', null, InputOption::VALUE_NONE, '[DBAL) Load only fixtures.') |
37
|
|
|
; |
38
|
2 |
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritdoc} |
42
|
|
|
*/ |
43
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
44
|
|
|
{ |
45
|
2 |
|
$io = new SymfonyStyle($input, $output); |
46
|
|
|
|
47
|
2 |
|
$io->title('Load the world! \o/'); |
48
|
|
|
|
49
|
2 |
|
$groups = $input->getOption('groups'); |
50
|
2 |
|
$excludeGroups = $input->getOption('exclude-groups'); |
51
|
|
|
|
52
|
2 |
|
$this->datagen->load($groups, $excludeGroups, [ |
53
|
|
|
'dbal' => [ |
54
|
2 |
|
'schema_only' => $input->getOption('dbal-schema-only'), |
55
|
2 |
|
'fixtures_only' => $input->getOption('dbal-fixtures-only'), |
56
|
|
|
], |
57
|
|
|
]); |
58
|
|
|
|
59
|
2 |
|
$io->success('Job DONE!'); |
60
|
2 |
|
} |
61
|
|
|
} |
62
|
|
|
|