2023-07-26 10:49:30 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-31 11:25:57 +00:00
|
|
|
namespace Wallabag\CoreBundle\Controller\Import;
|
2023-07-26 10:49:30 +00:00
|
|
|
|
|
|
|
use Craue\ConfigBundle\Util\Config;
|
|
|
|
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
use Wallabag\ImportBundle\Import\PocketHtmlImport;
|
|
|
|
use Wallabag\ImportBundle\Redis\Producer as RedisProducer;
|
|
|
|
|
|
|
|
class PocketHtmlController extends HtmlController
|
|
|
|
{
|
|
|
|
private PocketHtmlImport $pocketHtmlImport;
|
|
|
|
private Config $craueConfig;
|
|
|
|
private RabbitMqProducer $rabbitMqProducer;
|
|
|
|
private RedisProducer $redisProducer;
|
|
|
|
|
|
|
|
public function __construct(PocketHtmlImport $pocketHtmlImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer)
|
|
|
|
{
|
|
|
|
$this->pocketHtmlImport = $pocketHtmlImport;
|
|
|
|
$this->craueConfig = $craueConfig;
|
|
|
|
$this->rabbitMqProducer = $rabbitMqProducer;
|
|
|
|
$this->redisProducer = $redisProducer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-12-31 11:25:57 +00:00
|
|
|
* @Route("/import/pocket_html", name="import_pocket_html")
|
2023-07-26 10:49:30 +00:00
|
|
|
*/
|
|
|
|
public function indexAction(Request $request, TranslatorInterface $translator)
|
|
|
|
{
|
|
|
|
return parent::indexAction($request, $translator);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getImportService()
|
|
|
|
{
|
|
|
|
if ($this->craueConfig->get('import_with_rabbitmq')) {
|
|
|
|
$this->pocketHtmlImport->setProducer($this->rabbitMqProducer);
|
|
|
|
} elseif ($this->craueConfig->get('import_with_redis')) {
|
|
|
|
$this->pocketHtmlImport->setProducer($this->redisProducer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->pocketHtmlImport;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getImportTemplate()
|
|
|
|
{
|
|
|
|
return '@WallabagImport/PocketHtml/index.html.twig';
|
|
|
|
}
|
|
|
|
}
|