aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Controller
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-31 11:24:46 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-01-02 23:27:41 +0100
commit7019c7cf6c6af39c0f458769e20c3f9306477943 (patch)
tree12acceaa458cdf6d24367eba85f690265acddcdb /src/Wallabag/ImportBundle/Controller
parentb1d05721cf37ab94ec1a6837fe79cf19474dd0ff (diff)
downloadwallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.tar.gz
wallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.tar.zst
wallabag-7019c7cf6c6af39c0f458769e20c3f9306477943.zip
Add tagged services for import
- list services in /import - add url to import service - ImportBundle routing are now prefixed by /import - optimize flush in each import (flushing each 20 contents) - improve design of each import - add more tests
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller')
-rw-r--r--src/Wallabag/ImportBundle/Controller/ImportController.php6
-rw-r--r--src/Wallabag/ImportBundle/Controller/PocketController.php10
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php21
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;
8class ImportController extends Controller 8class 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;
8class PocketController extends Controller 8class 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;
10class WallabagV1Controller extends Controller 10class 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}