diff options
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller')
3 files changed, 21 insertions, 16 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php index 2a0d6ab5..c1486e38 100644 --- a/src/Wallabag/ImportBundle/Controller/ImportController.php +++ b/src/Wallabag/ImportBundle/Controller/ImportController.php | |||
@@ -8,10 +8,12 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |||
8 | class ImportController extends Controller | 8 | class ImportController extends Controller |
9 | { | 9 | { |
10 | /** | 10 | /** |
11 | * @Route("/import", name="import") | 11 | * @Route("/", name="import") |
12 | */ | 12 | */ |
13 | public function importAction() | 13 | public function importAction() |
14 | { | 14 | { |
15 | return $this->render('WallabagImportBundle:Import:index.html.twig', []); | 15 | return $this->render('WallabagImportBundle:Import:index.html.twig', [ |
16 | 'imports' => $this->get('wallabag_import.chain')->getAll(), | ||
17 | ]); | ||
16 | } | 18 | } |
17 | } | 19 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php index ebcee099..a0853383 100644 --- a/src/Wallabag/ImportBundle/Controller/PocketController.php +++ b/src/Wallabag/ImportBundle/Controller/PocketController.php | |||
@@ -8,15 +8,17 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |||
8 | class PocketController extends Controller | 8 | class PocketController extends Controller |
9 | { | 9 | { |
10 | /** | 10 | /** |
11 | * @Route("/import/pocket", name="import_pocket") | 11 | * @Route("/pocket", name="import_pocket") |
12 | */ | 12 | */ |
13 | public function indexAction() | 13 | public function indexAction() |
14 | { | 14 | { |
15 | return $this->render('WallabagImportBundle:Pocket:index.html.twig', []); | 15 | return $this->render('WallabagImportBundle:Pocket:index.html.twig', [ |
16 | 'import' => $this->get('wallabag_import.pocket.import'), | ||
17 | ]); | ||
16 | } | 18 | } |
17 | 19 | ||
18 | /** | 20 | /** |
19 | * @Route("/import/pocket/auth", name="import_pocket_auth") | 21 | * @Route("/pocket/auth", name="import_pocket_auth") |
20 | */ | 22 | */ |
21 | public function authAction() | 23 | public function authAction() |
22 | { | 24 | { |
@@ -32,7 +34,7 @@ class PocketController extends Controller | |||
32 | } | 34 | } |
33 | 35 | ||
34 | /** | 36 | /** |
35 | * @Route("/import/pocket/callback", name="import_pocket_callback") | 37 | * @Route("/pocket/callback", name="import_pocket_callback") |
36 | */ | 38 | */ |
37 | public function callbackAction() | 39 | public function callbackAction() |
38 | { | 40 | { |
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 | } |