pocketConsumer = $pocketConsumer; $this->readabilityConsumer = $readabilityConsumer; $this->wallabagV1Consumer = $wallabagV1Consumer; $this->wallabagV2Consumer = $wallabagV2Consumer; $this->firefoxConsumer = $firefoxConsumer; $this->chromeConsumer = $chromeConsumer; $this->instapaperConsumer = $instapaperConsumer; $this->pinboardConsumer = $pinboardConsumer; $this->deliciousConsumer = $deliciousConsumer; $this->elcuratorConsumer = $elcuratorConsumer; $this->shaarliConsumer = $shaarliConsumer; $this->pocketHtmlConsumer = $pocketHtmlConsumer; } /** * Count message in RabbitMQ queue. * * It get one message without acking it (so it'll stay in the queue) * which will include the total of *other* messages in the queue. * Adding one to that messages will result in the full total message. * * @param string $importService The import service related: pocket, readability, wallabag_v1 or wallabag_v2 */ public function getTotalMessage(string $importService): int { switch ($importService) { case 'pocket': $consumer = $this->pocketConsumer; break; case 'readability': $consumer = $this->readabilityConsumer; break; case 'wallabag_v1': $consumer = $this->wallabagV1Consumer; break; case 'wallabag_v2': $consumer = $this->wallabagV2Consumer; break; case 'firefox': $consumer = $this->firefoxConsumer; break; case 'chrome': $consumer = $this->chromeConsumer; break; case 'instapaper': $consumer = $this->instapaperConsumer; break; case 'pinboard': $consumer = $this->pinboardConsumer; break; case 'delicious': $consumer = $this->deliciousConsumer; break; case 'elcurator': $consumer = $this->elcuratorConsumer; break; case 'shaarli': $consumer = $this->shaarliConsumer; break; case 'pocket_html': $consumer = $this->pocketHtmlConsumer; break; default: return 0; } $message = $consumer->getChannel()->basic_get('wallabag.import.' . $importService); if (null === $message) { return 0; } return $message->delivery_info['message_count'] + 1; } }