container = $container; parent::__construct(); } protected function configure() { $this ->addArgument('serviceName', InputArgument::REQUIRED, 'Service to use: wallabag_v1, wallabag_v2, pocket, readability, pinboard, delicious, firefox, chrome or instapaper') ->addOption('maxIterations', '', InputOption::VALUE_OPTIONAL, 'Number of iterations before stopping', false) ; } protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Worker started at: ' . (new \DateTime())->format('d-m-Y G:i:s')); $output->writeln('Waiting for message ...'); $serviceName = $input->getArgument('serviceName'); if (!$this->container->has('wallabag.queue.redis.' . $serviceName) || !$this->container->has('wallabag.consumer.redis.' . $serviceName)) { throw new Exception(sprintf('No queue or consumer found for service name: "%s"', $input->getArgument('serviceName'))); } $worker = new QueueWorker( $this->container->get('wallabag.queue.redis.' . $serviceName), $this->container->get('wallabag.consumer.redis.' . $serviceName), (int) $input->getOption('maxIterations') ); $worker->start(); return 0; } }