1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Arp\LaminasDoctrine\Console\Command; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
8
|
|
|
use Symfony\Component\Console\Exception\InvalidArgumentException; |
9
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
|
|
|
10
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
11
|
|
|
use Symfony\Component\Console\Input\InputOption; |
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Inspired by @link https://github.com/doctrine/DoctrineFixturesBundle/issues/50 |
16
|
|
|
*/ |
17
|
|
|
final class RebuildCommand extends Command |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @throws InvalidArgumentException |
21
|
|
|
*/ |
22
|
|
|
public function configure(): void |
23
|
|
|
{ |
24
|
|
|
$this->setName('orm:schema-tool:rebuild') |
25
|
|
|
->setDescription('Drop, Create, Update and Load database fixtures in a single command') |
26
|
|
|
->setHelp( |
27
|
|
|
'Combines the schema-tool and fixture import commands into a single command so databases can be ' |
28
|
|
|
. 'easily rebuilt with the required fixture data' |
29
|
|
|
)->addOption( |
30
|
|
|
'disable-drop', |
31
|
|
|
null, |
32
|
|
|
InputOption::VALUE_NONE, |
33
|
|
|
'Prevent the schema-tool drop command from being executed' |
34
|
|
|
)->addOption( |
35
|
|
|
'disable-update', |
36
|
|
|
null, |
37
|
|
|
InputOption::VALUE_NONE, |
38
|
|
|
'Prevent the schema-tool update command from being executed' |
39
|
|
|
)->addOption( |
40
|
|
|
'disable-import', |
41
|
|
|
null, |
42
|
|
|
InputOption::VALUE_NONE, |
43
|
|
|
'Prevent the data fixtures import command from being executed' |
44
|
|
|
); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @throws InvalidArgumentException |
49
|
|
|
* @throws \Exception |
50
|
|
|
*/ |
51
|
|
|
public function execute(InputInterface $input, OutputInterface $output): int |
52
|
|
|
{ |
53
|
|
|
$application = $this->getApplication(); |
54
|
|
|
if (null === $application) { |
55
|
|
|
throw new InvalidArgumentException('The Doctrine Application is undefined'); |
56
|
|
|
} |
57
|
|
|
$output->writeln('Executing database rebuild commands'); |
58
|
|
|
|
59
|
|
|
$autoExit = $application->isAutoExitEnabled(); |
60
|
|
|
$application->setAutoExit(false); |
61
|
|
|
$application->setCatchExceptions(false); |
62
|
|
|
|
63
|
|
|
if (!$input->getOption('disable-drop')) { |
64
|
|
|
$output->writeln('Executing orm:schema:tool:drop'); |
65
|
|
|
|
66
|
|
|
$commandArguments = [ |
67
|
|
|
'command' => 'orm:schema-tool:drop', |
68
|
|
|
'--force' => true, |
69
|
|
|
]; |
70
|
|
|
$application->run(new ArrayInput($commandArguments)); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$output->writeln('Executing orm:schema:tool:update'); |
74
|
|
|
$commandArguments = [ |
75
|
|
|
'command' => 'orm:schema-tool:create', |
76
|
|
|
]; |
77
|
|
|
|
78
|
|
|
$application->run(new ArrayInput($commandArguments)); |
79
|
|
|
|
80
|
|
|
if (!$input->getOption('disable-update')) { |
81
|
|
|
$output->writeln('Executing orm:schema:tool:update'); |
82
|
|
|
|
83
|
|
|
$commandArguments = [ |
84
|
|
|
'command' => 'orm:schema-tool:update', |
85
|
|
|
'--force' => true, |
86
|
|
|
]; |
87
|
|
|
$application->run(new ArrayInput($commandArguments)); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
if (!$input->getOption('disable-import')) { |
91
|
|
|
$output->writeln('Executing data-fixture:import'); |
92
|
|
|
|
93
|
|
|
$commandArguments = [ |
94
|
|
|
'command' => 'data-fixture:import', |
95
|
|
|
'--append' => true, |
96
|
|
|
]; |
97
|
|
|
$application->run(new ArrayInput($commandArguments)); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
$application->setAutoExit($autoExit); |
101
|
|
|
$output->writeln('Rebuild completed successfully'); |
102
|
|
|
return 0; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths