1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OldSound\RabbitMqBundle\Command; |
4
|
|
|
|
5
|
|
|
use OldSound\RabbitMqBundle\Declarations\DeclarationsRegistry; |
6
|
|
|
use OldSound\RabbitMqBundle\Declarations\Declarator; |
7
|
|
|
use OldSound\RabbitMqBundle\RabbitMq\DynamicConsumer; |
|
|
|
|
8
|
|
|
use Symfony\Component\Console\Command\Command; |
9
|
|
|
use Symfony\Component\Console\Exception\InvalidOptionException; |
10
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
12
|
|
|
use Symfony\Component\Console\Input\InputOption; |
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
15
|
|
|
|
16
|
|
|
class DeclareCommand extends Command |
17
|
|
|
{ |
18
|
|
|
use ContainerAwareTrait; |
19
|
|
|
|
20
|
|
|
public function __construct( |
21
|
|
|
DeclarationsRegistry $declarationsRegistry |
22
|
|
|
) { |
23
|
|
|
parent::__construct(); |
24
|
|
|
$this->declarationsRegistry = $declarationsRegistry; |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
protected function configure() |
28
|
|
|
{ |
29
|
|
|
$this |
30
|
|
|
->setName('rabbitmq:declare') |
31
|
|
|
->addArgument('connection', InputArgument::OPTIONAL, 'Rabbitmq connection name', 'default') |
32
|
|
|
->setDescription('Sets up the Rabbit MQ fabric') |
33
|
|
|
->addOption('debug', 'd', InputOption::VALUE_NONE, 'Enable Debugging') |
34
|
|
|
; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
38
|
|
|
{ |
39
|
|
|
if (defined('AMQP_DEBUG') === false) { |
40
|
|
|
define('AMQP_DEBUG', (bool) $input->getOption('debug')); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$connection = $input->getArgument('connection'); |
44
|
|
|
$channelAlias = sprintf('old_sound_rabbit_mq.channel.%s', $connection); |
|
|
|
|
45
|
|
|
if(!$this->container->has($channelAlias)) { |
46
|
|
|
throw new InvalidOptionException('Connection is not exist'); |
47
|
|
|
}; |
48
|
|
|
|
49
|
|
|
$channel = $this->container->get($channelAlias); |
50
|
|
|
|
51
|
|
|
// TODO $output->writeln('Setting up the Rabbit MQ fabric'); |
52
|
|
|
|
53
|
|
|
$producers = []; |
54
|
|
|
$consumers = []; |
55
|
|
|
$exchanges = []; |
56
|
|
|
foreach ($producers as $producer) { |
57
|
|
|
// TODO $exchanges[] = $producer->exchange; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
foreach ($consumers as $consumer) { |
61
|
|
|
// TODO $exchanges[] = $producer->exchange; |
62
|
|
|
//$bindings[] = $producer->exchange; |
63
|
|
|
//$queues[] = $producer->exchange; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$declarator = new Declarator($channel); |
|
|
|
|
67
|
|
|
// $declarator->declareExchanges($exchanges); |
68
|
|
|
foreach ($exchanges as $exchange) { |
69
|
|
|
$declarator->declareForExchange($exchange); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return 0; |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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