X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FImportBundle%2FController%2FWallabagV1Controller.php;h=312c7a357f62781df70f62bb3016f11c8e7601e7;hb=822c877949aff8ae57677671115f8f4fc69588d5;hp=35fe620f8adaf83cbbb37e0953bbb34a2d83eafe;hpb=86719c63bf47686ca55020e6b0443344de36d45a;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php index 35fe620f..312c7a35 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php @@ -2,58 +2,40 @@ namespace Wallabag\ImportBundle\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Component\HttpFoundation\Request; -use Wallabag\ImportBundle\Form\Type\UploadImportType; -class WallabagV1Controller extends Controller +class WallabagV1Controller extends WallabagController { /** - * @Route("/wallabag-v1", name="import_wallabag_v1") + * {@inheritdoc} */ - public function indexAction(Request $request) + protected function getImportService() { - $form = $this->createForm(UploadImportType::class); - $form->handleRequest($request); - - $wallabag = $this->get('wallabag_import.wallabag_v1.import'); - - if ($form->isValid()) { - $file = $form->get('file')->getData(); - $name = $this->getUser()->getId().'.json'; - - if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { - $res = $wallabag - ->setUser($this->getUser()) - ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) - ->import(); + $service = $this->get('wallabag_import.wallabag_v1.import'); - $message = 'Import failed, please try again.'; - if (true === $res) { - $summary = $wallabag->getSummary(); - $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; - - unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); - } + if ($this->get('craue_config')->get('import_with_rabbitmq')) { + $service->setProducer($this->get('old_sound_rabbit_mq.import_wallabag_v1_producer')); + } elseif ($this->get('craue_config')->get('import_with_redis')) { + $service->setProducer($this->get('wallabag_import.producer.redis.wallabag_v1')); + } - $this->get('session')->getFlashBag()->add( - 'notice', - $message - ); + return $service; + } - return $this->redirect($this->generateUrl('homepage')); - } else { - $this->get('session')->getFlashBag()->add( - 'notice', - 'Error while processing import. Please verify your import file.' - ); - } - } + /** + * {@inheritdoc} + */ + protected function getImportTemplate() + { + return 'WallabagImportBundle:WallabagV1:index.html.twig'; + } - return $this->render('WallabagImportBundle:WallabagV1:index.html.twig', [ - 'form' => $form->createView(), - 'import' => $wallabag, - ]); + /** + * @Route("/wallabag-v1", name="import_wallabag_v1") + */ + public function indexAction(Request $request) + { + return parent::indexAction($request); } }