1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-26 18:21:02 +00:00
wallabag/src/Controller/Import/ShaarliController.php

54 lines
1.7 KiB
PHP
Raw Normal View History

2023-07-26 12:49:30 +02:00
<?php
2024-02-19 01:30:12 +01:00
namespace Wallabag\Controller\Import;
2023-07-26 12:49:30 +02:00
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
2025-03-11 00:54:02 +01:00
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
2023-07-26 12:49:30 +02:00
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
2024-02-19 01:30:12 +01:00
use Wallabag\Import\ShaarliImport;
use Wallabag\Redis\Producer as RedisProducer;
2023-07-26 12:49:30 +02:00
class ShaarliController extends HtmlController
{
private ShaarliImport $shaarliImport;
private Config $craueConfig;
private RabbitMqProducer $rabbitMqProducer;
private RedisProducer $redisProducer;
public function __construct(ShaarliImport $shaarliImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer)
{
$this->shaarliImport = $shaarliImport;
$this->craueConfig = $craueConfig;
$this->rabbitMqProducer = $rabbitMqProducer;
$this->redisProducer = $redisProducer;
}
/**
2025-03-10 01:15:45 +01:00
* @Route("/import/shaarli", name="import_shaarli", methods={"GET", "POST"})
2025-03-11 00:54:02 +01:00
* @IsGranted("IMPORT_ENTRIES")
2023-07-26 12:49:30 +02:00
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{
return parent::indexAction($request, $translator);
}
protected function getImportService()
{
if ($this->craueConfig->get('import_with_rabbitmq')) {
$this->shaarliImport->setProducer($this->rabbitMqProducer);
} elseif ($this->craueConfig->get('import_with_redis')) {
$this->shaarliImport->setProducer($this->redisProducer);
}
return $this->shaarliImport;
}
protected function getImportTemplate()
{
2024-02-19 00:03:14 +01:00
return 'Import/Shaarli/index.html.twig';
2023-07-26 12:49:30 +02:00
}
}