eMAGTechLabs /
RabbitMqBundle
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace OldSound\RabbitMqBundle\Command; |
||||
| 4 | |||||
| 5 | use Symfony\Component\Console\Command\Command; |
||||
| 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 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * Command to delete a queue |
||||
| 14 | */ |
||||
| 15 | class DeleteCommand extends Command |
||||
| 16 | { |
||||
| 17 | protected function configure() |
||||
| 18 | { |
||||
| 19 | $this->addArgument('name', InputArgument::REQUIRED, 'Consumer Name') |
||||
| 20 | ->setDescription('Delete a consumer\'s queue') |
||||
| 21 | ->addOption('no-confirmation', null, InputOption::VALUE_NONE, 'Whether it must be confirmed before deleting'); |
||||
| 22 | |||||
| 23 | $this->setName('rabbitmq:delete'); |
||||
| 24 | } |
||||
| 25 | |||||
| 26 | /** |
||||
| 27 | * @param InputInterface $input |
||||
| 28 | * @param OutputInterface $output |
||||
| 29 | * |
||||
| 30 | * @return int |
||||
| 31 | */ |
||||
| 32 | protected function execute(InputInterface $input, OutputInterface $output) |
||||
| 33 | { |
||||
| 34 | $noConfirmation = (bool) $input->getOption('no-confirmation'); |
||||
| 35 | |||||
| 36 | if (!$noConfirmation && $input->isInteractive()) { |
||||
| 37 | $question = new ConfirmationQuestion( |
||||
| 38 | sprintf( |
||||
| 39 | '<question>Are you sure you wish to delete "%s" consumer\'s queue? (y/n)</question>', |
||||
| 40 | $input->getArgument('name') |
||||
| 41 | ), |
||||
| 42 | false |
||||
| 43 | ); |
||||
| 44 | |||||
| 45 | if (!$this->getHelper('question')->ask($input, $output, $question)) { |
||||
| 46 | $output->writeln('<error>Deletion cancelled!</error>'); |
||||
| 47 | |||||
| 48 | return 1; |
||||
| 49 | } |
||||
| 50 | } |
||||
| 51 | |||||
| 52 | $this->consumer = $this->getContainer() |
||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
The method
getContainer() does not exist on OldSound\RabbitMqBundle\Command\DeleteCommand.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 53 | ->get(sprintf($this->getConsumerService(), $input->getArgument('name'))); |
||||
|
0 ignored issues
–
show
The method
getConsumerService() does not exist on OldSound\RabbitMqBundle\Command\DeleteCommand.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 54 | $this->consumer->delete(); |
||||
| 55 | |||||
| 56 | return 0; |
||||
| 57 | } |
||||
| 58 | } |
||||
| 59 |