/**
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @throws \InvalidArgumentException When the number of messages to consume is less than 0
  * @throws \BadFunctionCallException When the pcntl is not installed and option -s is true
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     if (defined('AMQP_WITHOUT_SIGNALS') === false) {
         define('AMQP_WITHOUT_SIGNALS', $input->getOption('without-signals'));
     }
     if (!AMQP_WITHOUT_SIGNALS && extension_loaded('pcntl')) {
         if (!function_exists('pcntl_signal')) {
             throw new \BadFunctionCallException("Function 'pcntl_signal' is referenced in the php.ini 'disable_functions' and can't be called.");
         }
         pcntl_signal(SIGTERM, array($this, 'signalTerm'));
         pcntl_signal(SIGINT, array($this, 'signalInt'));
         pcntl_signal(SIGHUP, array($this, 'signalHup'));
     }
     if (defined('AMQP_DEBUG') === false) {
         define('AMQP_DEBUG', (bool) $input->getOption('debug'));
     }
     if (($this->amount = $input->getOption('messages')) < 0) {
         throw new \InvalidArgumentException("The -m option should be null or greater than 0");
     }
     $this->consumer = $this->registry->getConsumer($input->getArgument('name'));
     if (!is_null($input->getOption('memory-limit')) && ctype_digit((string) $input->getOption('memory-limit')) && $input->getOption('memory-limit') > 0) {
         $this->consumer->setMemoryLimit($input->getOption('memory-limit'));
     }
     if ($routingKey = $input->getOption('route')) {
         $this->consumer->setRoutingKey($routingKey);
     }
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $noConfirmation = (bool) $input->getOption('no-confirmation');
     if (!$noConfirmation && $input->isInteractive()) {
         $confirmation = $this->getHelper('dialog')->askConfirmation($output, sprintf('<question>Are you sure you wish to purge "%s" queue? (y/n)</question>', $input->getArgument('name')), false);
         if (!$confirmation) {
             $output->writeln('<error>Purging cancelled!</error>');
             return 1;
         }
     }
     /** @var Consumer $consumer */
     $consumer = $this->registry->getConsumer($input->getArgument('name'));
     $consumer->purge($input->getArgument('name'));
     return 0;
 }