forked from wallabag/wallabag
49 lines
1.5 KiB
PHP
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\ShaarliImport;
|
|
use Wallabag\Redis\Producer as RedisProducer;
|
|
|
|
class ShaarliController extends HtmlController
|
|
{
|
|
public function __construct(
|
|
private ShaarliImport $shaarliImport,
|
|
private Config $craueConfig,
|
|
private RabbitMqProducer $rabbitMqProducer,
|
|
private RedisProducer $redisProducer,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @Route("/import/shaarli", name="import_shaarli", 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->shaarliImport->setProducer($this->rabbitMqProducer);
|
|
} elseif ($this->craueConfig->get('import_with_redis')) {
|
|
$this->shaarliImport->setProducer($this->redisProducer);
|
|
}
|
|
|
|
return $this->shaarliImport;
|
|
}
|
|
|
|
protected function getImportTemplate()
|
|
{
|
|
return 'Import/Shaarli/index.html.twig';
|
|
}
|
|
}
|