1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
8
|
|
|
use Symfony\Component\Lock\LockFactory; |
|
|
|
|
9
|
|
|
use ControleOnline\Service\DatabaseSwitchService; |
|
|
|
|
10
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
|
|
|
12
|
|
|
|
13
|
|
|
abstract class DefaultCommand extends Command |
14
|
|
|
{ |
15
|
|
|
protected $input; |
16
|
|
|
protected $output; |
17
|
|
|
protected $lock; |
18
|
|
|
protected $lockFactory; |
19
|
|
|
protected $databaseSwitchService; |
20
|
|
|
|
21
|
|
|
abstract protected function runCommand(): int; |
22
|
|
|
|
23
|
|
|
public function __construct(string $name) |
24
|
|
|
{ |
25
|
|
|
parent::__construct($name); |
26
|
|
|
$this->lock = $this->lockFactory->createLock($name); |
27
|
|
|
$this->addOption('domain', ['d'], InputOption::VALUE_OPTIONAL, 'Database domain identifier'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
31
|
|
|
{ |
32
|
|
|
$this->input = $input; |
33
|
|
|
$this->output = $output; |
34
|
|
|
|
35
|
|
|
$domain = $input->getOption('domain'); |
36
|
|
|
|
37
|
|
|
if ($domain) { |
38
|
|
|
$this->output->writeln(sprintf('Executando migrações para o domínio: %s', $domain)); |
39
|
|
|
$this->databaseSwitchService->switchDatabaseByDomain($domain); |
40
|
|
|
return $this->runCommand(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$domains = $this->databaseSwitchService->getAllDomains(); |
44
|
|
|
|
45
|
|
|
foreach ($domains as $domain) { |
46
|
|
|
$this->output->writeln(sprintf('Executando migrações para o domínio: %s', $domain)); |
47
|
|
|
$this->databaseSwitchService->switchDatabaseByDomain($domain); |
48
|
|
|
$this->runCommand(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return Command::SUCCESS; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function __destruct() |
55
|
|
|
{ |
56
|
|
|
$this->lock->release(); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
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