diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2015-12-30 12:23:51 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-02 23:27:41 +0100 |
commit | 252ebd60719d32ec954d0519c9edf2b52b03310c (patch) | |
tree | 044c97abeda75c33901d8bfcd33fa107279b1778 /src/Wallabag/ImportBundle/Controller/ImportController.php | |
parent | b4b592a0c0ee356e81775baf8f9976288d7b686c (diff) | |
download | wallabag-252ebd60719d32ec954d0519c9edf2b52b03310c.tar.gz wallabag-252ebd60719d32ec954d0519c9edf2b52b03310c.tar.zst wallabag-252ebd60719d32ec954d0519c9edf2b52b03310c.zip |
Rewrote Pocket Import
For the moment, we won't do a queue system, just a plain synchronous import.
We also use ContentProxy to grab content for each article from Pocket.
Error from Pocket are now logged using the logger.
The ImportInterface need to be simple and not related to oAuth (not all import will use that method).
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller/ImportController.php')
-rw-r--r-- | src/Wallabag/ImportBundle/Controller/ImportController.php | 48 |
1 files changed, 2 insertions, 46 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php index 6ebd6a0a..2a0d6ab5 100644 --- a/src/Wallabag/ImportBundle/Controller/ImportController.php +++ b/src/Wallabag/ImportBundle/Controller/ImportController.php | |||
@@ -4,58 +4,14 @@ namespace Wallabag\ImportBundle\Controller; | |||
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
7 | use Symfony\Component\Console\Input\ArrayInput; | ||
8 | use Symfony\Component\Console\Output\NullOutput; | ||
9 | use Symfony\Component\HttpFoundation\Request; | ||
10 | use Wallabag\ImportBundle\Command\ImportCommand; | ||
11 | use Wallabag\ImportBundle\Form\Type\UploadImportType; | ||
12 | 7 | ||
13 | class ImportController extends Controller | 8 | class ImportController extends Controller |
14 | { | 9 | { |
15 | /** | 10 | /** |
16 | * @Route("/import", name="import") | 11 | * @Route("/import", name="import") |
17 | */ | 12 | */ |
18 | public function importAction(Request $request) | 13 | public function importAction() |
19 | { | 14 | { |
20 | $importForm = $this->createForm(new UploadImportType()); | 15 | return $this->render('WallabagImportBundle:Import:index.html.twig', []); |
21 | $importForm->handleRequest($request); | ||
22 | $user = $this->getUser(); | ||
23 | |||
24 | if ($importForm->isValid()) { | ||
25 | $file = $importForm->get('file')->getData(); | ||
26 | $name = $user->getId().'.json'; | ||
27 | $dir = __DIR__.'/../../../../web/uploads/import'; | ||
28 | |||
29 | if (in_array($file->getMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($dir, $name)) { | ||
30 | $command = new ImportCommand(); | ||
31 | $command->setContainer($this->container); | ||
32 | $input = new ArrayInput(array('userId' => $user->getId())); | ||
33 | $return = $command->run($input, new NullOutput()); | ||
34 | |||
35 | if ($return == 0) { | ||
36 | $this->get('session')->getFlashBag()->add( | ||
37 | 'notice', | ||
38 | 'Import successful' | ||
39 | ); | ||
40 | } else { | ||
41 | $this->get('session')->getFlashBag()->add( | ||
42 | 'notice', | ||
43 | 'Import failed' | ||
44 | ); | ||
45 | } | ||
46 | |||
47 | return $this->redirect('/'); | ||
48 | } else { | ||
49 | $this->get('session')->getFlashBag()->add( | ||
50 | 'notice', | ||
51 | 'Error while processing import. Please verify your import file.' | ||
52 | ); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | return $this->render('WallabagImportBundle:Import:index.html.twig', array( | ||
57 | 'form' => array( | ||
58 | 'import' => $importForm->createView(), ), | ||
59 | )); | ||
60 | } | 16 | } |
61 | } | 17 | } |