Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConsumerListCommand.php
Go to the documentation of this file.
1 <?php
7 
8 use Symfony\Component\Console\Command\Command;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
13 
17 class ConsumerListCommand extends Command
18 {
19  const COMMAND_QUEUE_CONSUMERS_LIST = 'queue:consumers:list';
20 
24  private $consumerConfig;
25 
34  public function __construct(QueueConfig $queueConfig, $name = null)
35  {
36  parent::__construct($name);
37  }
38 
42  protected function execute(InputInterface $input, OutputInterface $output)
43  {
44  $consumers = $this->getConsumers();
45  $output->writeln($consumers);
46  return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
47  }
48 
52  protected function configure()
53  {
54  $this->setName(self::COMMAND_QUEUE_CONSUMERS_LIST);
55  $this->setDescription('List of MessageQueue consumers');
56  $this->setHelp(
57  <<<HELP
58 This command shows list of MessageQueue consumers.
59 HELP
60  );
61  parent::configure();
62  }
63 
67  private function getConsumers()
68  {
69  $consumerNames = [];
70  foreach ($this->getConsumerConfig()->getConsumers() as $consumer) {
71  $consumerNames[] = $consumer->getName();
72  }
73  return $consumerNames;
74  }
75 
83  private function getConsumerConfig()
84  {
85  if ($this->consumerConfig === null) {
86  $this->consumerConfig = \Magento\Framework\App\ObjectManager::getInstance()->get(ConsumerConfig::class);
87  }
88  return $this->consumerConfig;
89  }
90 }
execute(InputInterface $input, OutputInterface $output)
__construct(QueueConfig $queueConfig, $name=null)
if(!isset($_GET['name'])) $name
Definition: log.php:14