1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MyOnlineStore\Bundle\RabbitMqManagerBundle\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
|
11
|
|
|
final class DownloadManagementToolCommand extends ContainerAwareCommand |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @inheritdoc |
15
|
|
|
*/ |
16
|
1 |
|
protected function configure() |
17
|
|
|
{ |
18
|
1 |
|
$this |
19
|
1 |
|
->addArgument('filename', InputArgument::OPTIONAL, 'Filename, for path see: rabbit_mq_manager.path', 'rabbitmqadmin') |
20
|
1 |
|
->addOption('hostname', null, InputOption::VALUE_REQUIRED, 'Hostname', 'localhost') |
21
|
1 |
|
->addOption('port', null, InputOption::VALUE_REQUIRED, 'Port', 15672) |
22
|
1 |
|
->setName('rabbitmq-manager:download:management-tool') |
23
|
1 |
|
->setDescription('Download rabbitmqadmin management tool'); |
24
|
1 |
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @inheritdoc |
28
|
|
|
*/ |
29
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
30
|
|
|
{ |
31
|
1 |
|
$client = $this->getContainer()->get('myonlinestore_rabbitmq_manager.http_client'); |
32
|
1 |
|
$filesystem = $this->getContainer()->get('myonlinestore_rabbitmq_manager.filesystem'); |
33
|
|
|
|
34
|
1 |
|
$request = $client->createRequest( |
35
|
1 |
|
'GET', |
36
|
1 |
|
sprintf( |
37
|
1 |
|
'http://%s:%s/cli/rabbitmqadmin', |
38
|
1 |
|
$input->getOption('hostname'), |
39
|
1 |
|
$input->getOption('port') |
40
|
1 |
|
) |
41
|
1 |
|
); |
42
|
|
|
|
43
|
1 |
|
$filesystem->put( |
44
|
1 |
|
$input->getArgument('filename'), |
45
|
1 |
|
$client->send($request)->getBody()->getContents() |
46
|
1 |
|
); |
47
|
1 |
|
} |
48
|
|
|
} |
49
|
|
|
|