diff options
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php')
-rw-r--r-- | src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php index de200184..e50a6c35 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php | |||
@@ -10,20 +10,20 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType; | |||
10 | class WallabagV1Controller extends Controller | 10 | class WallabagV1Controller extends Controller |
11 | { | 11 | { |
12 | /** | 12 | /** |
13 | * @Route("/import/wallabag-v1", name="import_wallabag_v1") | 13 | * @Route("/wallabag-v1", name="import_wallabag_v1") |
14 | */ | 14 | */ |
15 | public function indexAction(Request $request) | 15 | public function indexAction(Request $request) |
16 | { | 16 | { |
17 | $importForm = $this->createForm(new UploadImportType()); | 17 | $form = $this->createForm(new UploadImportType()); |
18 | $importForm->handleRequest($request); | 18 | $form->handleRequest($request); |
19 | $user = $this->getUser(); | ||
20 | 19 | ||
21 | if ($importForm->isValid()) { | 20 | $wallabag = $this->get('wallabag_import.wallabag_v1.import'); |
22 | $file = $importForm->get('file')->getData(); | 21 | |
23 | $name = $user->getId().'.json'; | 22 | if ($form->isValid()) { |
23 | $file = $form->get('file')->getData(); | ||
24 | $name = $this->getUser()->getId().'.json'; | ||
24 | 25 | ||
25 | if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | 26 | if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { |
26 | $wallabag = $this->get('wallabag_import.wallabag_v1.import'); | ||
27 | $res = $wallabag | 27 | $res = $wallabag |
28 | ->setUser($this->getUser()) | 28 | ->setUser($this->getUser()) |
29 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | 29 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) |
@@ -34,7 +34,7 @@ class WallabagV1Controller extends Controller | |||
34 | $summary = $wallabag->getSummary(); | 34 | $summary = $wallabag->getSummary(); |
35 | $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; | 35 | $message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.'; |
36 | 36 | ||
37 | @unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); | 37 | unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); |
38 | } | 38 | } |
39 | 39 | ||
40 | $this->get('session')->getFlashBag()->add( | 40 | $this->get('session')->getFlashBag()->add( |
@@ -52,7 +52,8 @@ class WallabagV1Controller extends Controller | |||
52 | } | 52 | } |
53 | 53 | ||
54 | return $this->render('WallabagImportBundle:WallabagV1:index.html.twig', [ | 54 | return $this->render('WallabagImportBundle:WallabagV1:index.html.twig', [ |
55 | 'form' => $importForm->createView(), | 55 | 'form' => $form->createView(), |
56 | 'import' => $wallabag, | ||
56 | ]); | 57 | ]); |
57 | } | 58 | } |
58 | } | 59 | } |