Files
wallabag/src/Controller/Import/PocketHtmlController.php
2025-04-07 09:17:32 +02:00

49 lines
1.5 KiB
PHP

<?php
namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use Wallabag\Import\PocketHtmlImport;
use Wallabag\Redis\Producer as RedisProducer;
class PocketHtmlController extends HtmlController
{
public function __construct(
private PocketHtmlImport $pocketHtmlImport,
private Config $craueConfig,
private RabbitMqProducer $rabbitMqProducer,
private RedisProducer $redisProducer,
) {
}
/**
* @Route("/import/pocket_html", name="import_pocket_html", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
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 'Import/PocketHtml/index.html.twig';
}
}