diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-10-23 11:09:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 11:09:17 +0200 |
commit | 1953a872932a63792293b4aec087880265ba89f7 (patch) | |
tree | fd16599e737fcdaf193c933ef3ec4a4ee248b117 /src/Wallabag/ImportBundle/Controller | |
parent | d83d25dadec2c38460a32d96f5d2903426fec9d3 (diff) | |
parent | 702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff) | |
download | wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.gz wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.zst wallabag-1953a872932a63792293b4aec087880265ba89f7.zip |
Merge pull request #3011 from wallabag/2.3
wallabag 2.3.0
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller')
11 files changed, 134 insertions, 133 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php index e119098f..77a7a904 100644 --- a/src/Wallabag/ImportBundle/Controller/BrowserController.php +++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\ImportBundle\Controller; | 3 | namespace Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Symfony\Component\HttpFoundation\Response; | 8 | use Symfony\Component\HttpFoundation\Response; |
9 | use Wallabag\ImportBundle\Form\Type\UploadImportType; | 9 | use Wallabag\ImportBundle\Form\Type\UploadImportType; |
@@ -11,20 +11,6 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType; | |||
11 | abstract class BrowserController extends Controller | 11 | abstract class BrowserController extends Controller |
12 | { | 12 | { |
13 | /** | 13 | /** |
14 | * Return the service to handle the import. | ||
15 | * | ||
16 | * @return \Wallabag\ImportBundle\Import\ImportInterface | ||
17 | */ | ||
18 | abstract protected function getImportService(); | ||
19 | |||
20 | /** | ||
21 | * Return the template used for the form. | ||
22 | * | ||
23 | * @return string | ||
24 | */ | ||
25 | abstract protected function getImportTemplate(); | ||
26 | |||
27 | /** | ||
28 | * @Route("/browser", name="import_browser") | 14 | * @Route("/browser", name="import_browser") |
29 | * | 15 | * |
30 | * @param Request $request | 16 | * @param Request $request |
@@ -42,11 +28,11 @@ abstract class BrowserController extends Controller | |||
42 | if ($form->isSubmitted() && $form->isValid()) { | 28 | if ($form->isSubmitted() && $form->isValid()) { |
43 | $file = $form->get('file')->getData(); | 29 | $file = $form->get('file')->getData(); |
44 | $markAsRead = $form->get('mark_as_read')->getData(); | 30 | $markAsRead = $form->get('mark_as_read')->getData(); |
45 | $name = $this->getUser()->getId().'.json'; | 31 | $name = $this->getUser()->getId() . '.json'; |
46 | 32 | ||
47 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | 33 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { |
48 | $res = $wallabag | 34 | $res = $wallabag |
49 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | 35 | ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name) |
50 | ->setMarkAsRead($markAsRead) | 36 | ->setMarkAsRead($markAsRead) |
51 | ->import(); | 37 | ->import(); |
52 | 38 | ||
@@ -65,7 +51,7 @@ abstract class BrowserController extends Controller | |||
65 | ]); | 51 | ]); |
66 | } | 52 | } |
67 | 53 | ||
68 | unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); | 54 | unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name); |
69 | } | 55 | } |
70 | 56 | ||
71 | $this->get('session')->getFlashBag()->add( | 57 | $this->get('session')->getFlashBag()->add( |
@@ -74,12 +60,11 @@ abstract class BrowserController extends Controller | |||
74 | ); | 60 | ); |
75 | 61 | ||
76 | return $this->redirect($this->generateUrl('homepage')); | 62 | return $this->redirect($this->generateUrl('homepage')); |
77 | } else { | 63 | } |
78 | $this->get('session')->getFlashBag()->add( | 64 | $this->get('session')->getFlashBag()->add( |
79 | 'notice', | 65 | 'notice', |
80 | 'flashes.import.notice.failed_on_file' | 66 | 'flashes.import.notice.failed_on_file' |
81 | ); | 67 | ); |
82 | } | ||
83 | } | 68 | } |
84 | 69 | ||
85 | return $this->render($this->getImportTemplate(), [ | 70 | return $this->render($this->getImportTemplate(), [ |
@@ -87,4 +72,18 @@ abstract class BrowserController extends Controller | |||
87 | 'import' => $wallabag, | 72 | 'import' => $wallabag, |
88 | ]); | 73 | ]); |
89 | } | 74 | } |
75 | |||
76 | /** | ||
77 | * Return the service to handle the import. | ||
78 | * | ||
79 | * @return \Wallabag\ImportBundle\Import\ImportInterface | ||
80 | */ | ||
81 | abstract protected function getImportService(); | ||
82 | |||
83 | /** | ||
84 | * Return the template used for the form. | ||
85 | * | ||
86 | * @return string | ||
87 | */ | ||
88 | abstract protected function getImportTemplate(); | ||
90 | } | 89 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/ChromeController.php b/src/Wallabag/ImportBundle/Controller/ChromeController.php index 454f3347..0cb418a1 100644 --- a/src/Wallabag/ImportBundle/Controller/ChromeController.php +++ b/src/Wallabag/ImportBundle/Controller/ChromeController.php | |||
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request; | |||
8 | class ChromeController extends BrowserController | 8 | class ChromeController extends BrowserController |
9 | { | 9 | { |
10 | /** | 10 | /** |
11 | * @Route("/chrome", name="import_chrome") | ||
12 | */ | ||
13 | public function indexAction(Request $request) | ||
14 | { | ||
15 | return parent::indexAction($request); | ||
16 | } | ||
17 | |||
18 | /** | ||
11 | * {@inheritdoc} | 19 | * {@inheritdoc} |
12 | */ | 20 | */ |
13 | protected function getImportService() | 21 | protected function getImportService() |
@@ -30,12 +38,4 @@ class ChromeController extends BrowserController | |||
30 | { | 38 | { |
31 | return 'WallabagImportBundle:Chrome:index.html.twig'; | 39 | return 'WallabagImportBundle:Chrome:index.html.twig'; |
32 | } | 40 | } |
33 | |||
34 | /** | ||
35 | * @Route("/chrome", name="import_chrome") | ||
36 | */ | ||
37 | public function indexAction(Request $request) | ||
38 | { | ||
39 | return parent::indexAction($request); | ||
40 | } | ||
41 | } | 41 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/FirefoxController.php b/src/Wallabag/ImportBundle/Controller/FirefoxController.php index c329b9c4..88697f9d 100644 --- a/src/Wallabag/ImportBundle/Controller/FirefoxController.php +++ b/src/Wallabag/ImportBundle/Controller/FirefoxController.php | |||
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request; | |||
8 | class FirefoxController extends BrowserController | 8 | class FirefoxController extends BrowserController |
9 | { | 9 | { |
10 | /** | 10 | /** |
11 | * @Route("/firefox", name="import_firefox") | ||
12 | */ | ||
13 | public function indexAction(Request $request) | ||
14 | { | ||
15 | return parent::indexAction($request); | ||
16 | } | ||
17 | |||
18 | /** | ||
11 | * {@inheritdoc} | 19 | * {@inheritdoc} |
12 | */ | 20 | */ |
13 | protected function getImportService() | 21 | protected function getImportService() |
@@ -30,12 +38,4 @@ class FirefoxController extends BrowserController | |||
30 | { | 38 | { |
31 | return 'WallabagImportBundle:Firefox:index.html.twig'; | 39 | return 'WallabagImportBundle:Firefox:index.html.twig'; |
32 | } | 40 | } |
33 | |||
34 | /** | ||
35 | * @Route("/firefox", name="import_firefox") | ||
36 | */ | ||
37 | public function indexAction(Request $request) | ||
38 | { | ||
39 | return parent::indexAction($request); | ||
40 | } | ||
41 | } | 41 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php index 237c748e..7e4fd174 100644 --- a/src/Wallabag/ImportBundle/Controller/ImportController.php +++ b/src/Wallabag/ImportBundle/Controller/ImportController.php | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\ImportBundle\Controller; | 3 | namespace Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | 7 | ||
8 | class ImportController extends Controller | 8 | class ImportController extends Controller |
9 | { | 9 | { |
@@ -86,9 +86,9 @@ class ImportController extends Controller | |||
86 | private function getTotalMessageInRabbitQueue($importService) | 86 | private function getTotalMessageInRabbitQueue($importService) |
87 | { | 87 | { |
88 | $message = $this | 88 | $message = $this |
89 | ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer') | 89 | ->get('old_sound_rabbit_mq.import_' . $importService . '_consumer') |
90 | ->getChannel() | 90 | ->getChannel() |
91 | ->basic_get('wallabag.import.'.$importService); | 91 | ->basic_get('wallabag.import.' . $importService); |
92 | 92 | ||
93 | if (null === $message) { | 93 | if (null === $message) { |
94 | return 0; | 94 | return 0; |
diff --git a/src/Wallabag/ImportBundle/Controller/InstapaperController.php b/src/Wallabag/ImportBundle/Controller/InstapaperController.php index 0251acb9..550679c3 100644 --- a/src/Wallabag/ImportBundle/Controller/InstapaperController.php +++ b/src/Wallabag/ImportBundle/Controller/InstapaperController.php | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\ImportBundle\Controller; | 3 | namespace Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Wallabag\ImportBundle\Form\Type\UploadImportType; | 8 | use Wallabag\ImportBundle\Form\Type\UploadImportType; |
9 | 9 | ||
@@ -29,11 +29,11 @@ class InstapaperController extends Controller | |||
29 | if ($form->isSubmitted() && $form->isValid()) { | 29 | if ($form->isSubmitted() && $form->isValid()) { |
30 | $file = $form->get('file')->getData(); | 30 | $file = $form->get('file')->getData(); |
31 | $markAsRead = $form->get('mark_as_read')->getData(); | 31 | $markAsRead = $form->get('mark_as_read')->getData(); |
32 | $name = 'instapaper_'.$this->getUser()->getId().'.csv'; | 32 | $name = 'instapaper_' . $this->getUser()->getId() . '.csv'; |
33 | 33 | ||
34 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | 34 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { |
35 | $res = $instapaper | 35 | $res = $instapaper |
36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | 36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name) |
37 | ->setMarkAsRead($markAsRead) | 37 | ->setMarkAsRead($markAsRead) |
38 | ->import(); | 38 | ->import(); |
39 | 39 | ||
@@ -52,7 +52,7 @@ class InstapaperController extends Controller | |||
52 | ]); | 52 | ]); |
53 | } | 53 | } |
54 | 54 | ||
55 | unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); | 55 | unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name); |
56 | } | 56 | } |
57 | 57 | ||
58 | $this->get('session')->getFlashBag()->add( | 58 | $this->get('session')->getFlashBag()->add( |
@@ -61,12 +61,12 @@ class InstapaperController extends Controller | |||
61 | ); | 61 | ); |
62 | 62 | ||
63 | return $this->redirect($this->generateUrl('homepage')); | 63 | return $this->redirect($this->generateUrl('homepage')); |
64 | } else { | ||
65 | $this->get('session')->getFlashBag()->add( | ||
66 | 'notice', | ||
67 | 'flashes.import.notice.failed_on_file' | ||
68 | ); | ||
69 | } | 64 | } |
65 | |||
66 | $this->get('session')->getFlashBag()->add( | ||
67 | 'notice', | ||
68 | 'flashes.import.notice.failed_on_file' | ||
69 | ); | ||
70 | } | 70 | } |
71 | 71 | ||
72 | return $this->render('WallabagImportBundle:Instapaper:index.html.twig', [ | 72 | return $this->render('WallabagImportBundle:Instapaper:index.html.twig', [ |
diff --git a/src/Wallabag/ImportBundle/Controller/PinboardController.php b/src/Wallabag/ImportBundle/Controller/PinboardController.php index d0ad8aa8..0e57fd41 100644 --- a/src/Wallabag/ImportBundle/Controller/PinboardController.php +++ b/src/Wallabag/ImportBundle/Controller/PinboardController.php | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\ImportBundle\Controller; | 3 | namespace Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Wallabag\ImportBundle\Form\Type\UploadImportType; | 8 | use Wallabag\ImportBundle\Form\Type\UploadImportType; |
9 | 9 | ||
@@ -29,11 +29,11 @@ class PinboardController extends Controller | |||
29 | if ($form->isSubmitted() && $form->isValid()) { | 29 | if ($form->isSubmitted() && $form->isValid()) { |
30 | $file = $form->get('file')->getData(); | 30 | $file = $form->get('file')->getData(); |
31 | $markAsRead = $form->get('mark_as_read')->getData(); | 31 | $markAsRead = $form->get('mark_as_read')->getData(); |
32 | $name = 'pinboard_'.$this->getUser()->getId().'.json'; | 32 | $name = 'pinboard_' . $this->getUser()->getId() . '.json'; |
33 | 33 | ||
34 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | 34 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { |
35 | $res = $pinboard | 35 | $res = $pinboard |
36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | 36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name) |
37 | ->setMarkAsRead($markAsRead) | 37 | ->setMarkAsRead($markAsRead) |
38 | ->import(); | 38 | ->import(); |
39 | 39 | ||
@@ -52,7 +52,7 @@ class PinboardController extends Controller | |||
52 | ]); | 52 | ]); |
53 | } | 53 | } |
54 | 54 | ||
55 | unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); | 55 | unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name); |
56 | } | 56 | } |
57 | 57 | ||
58 | $this->get('session')->getFlashBag()->add( | 58 | $this->get('session')->getFlashBag()->add( |
@@ -61,12 +61,12 @@ class PinboardController extends Controller | |||
61 | ); | 61 | ); |
62 | 62 | ||
63 | return $this->redirect($this->generateUrl('homepage')); | 63 | return $this->redirect($this->generateUrl('homepage')); |
64 | } else { | ||
65 | $this->get('session')->getFlashBag()->add( | ||
66 | 'notice', | ||
67 | 'flashes.import.notice.failed_on_file' | ||
68 | ); | ||
69 | } | 64 | } |
65 | |||
66 | $this->get('session')->getFlashBag()->add( | ||
67 | 'notice', | ||
68 | 'flashes.import.notice.failed_on_file' | ||
69 | ); | ||
70 | } | 70 | } |
71 | 71 | ||
72 | return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [ | 72 | return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [ |
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php index 56be5cbf..9f28819a 100644 --- a/src/Wallabag/ImportBundle/Controller/PocketController.php +++ b/src/Wallabag/ImportBundle/Controller/PocketController.php | |||
@@ -2,34 +2,15 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\ImportBundle\Controller; | 3 | namespace Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
8 | use Symfony\Component\HttpFoundation\Request; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
9 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | 7 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
8 | use Symfony\Component\HttpFoundation\Request; | ||
9 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
10 | 10 | ||
11 | class PocketController extends Controller | 11 | class PocketController extends Controller |
12 | { | 12 | { |
13 | /** | 13 | /** |
14 | * Return Pocket Import Service with or without RabbitMQ enabled. | ||
15 | * | ||
16 | * @return \Wallabag\ImportBundle\Import\PocketImport | ||
17 | */ | ||
18 | private function getPocketImportService() | ||
19 | { | ||
20 | $pocket = $this->get('wallabag_import.pocket.import'); | ||
21 | $pocket->setUser($this->getUser()); | ||
22 | |||
23 | if ($this->get('craue_config')->get('import_with_rabbitmq')) { | ||
24 | $pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer')); | ||
25 | } elseif ($this->get('craue_config')->get('import_with_redis')) { | ||
26 | $pocket->setProducer($this->get('wallabag_import.producer.redis.pocket')); | ||
27 | } | ||
28 | |||
29 | return $pocket; | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * @Route("/pocket", name="import_pocket") | 14 | * @Route("/pocket", name="import_pocket") |
34 | */ | 15 | */ |
35 | public function indexAction() | 16 | public function indexAction() |
@@ -70,7 +51,7 @@ class PocketController extends Controller | |||
70 | $this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']); | 51 | $this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']); |
71 | 52 | ||
72 | return $this->redirect( | 53 | return $this->redirect( |
73 | 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), | 54 | 'https://getpocket.com/auth/authorize?request_token=' . $requestToken . '&redirect_uri=' . $this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), |
74 | 301 | 55 | 301 |
75 | ); | 56 | ); |
76 | } | 57 | } |
@@ -117,4 +98,23 @@ class PocketController extends Controller | |||
117 | 98 | ||
118 | return $this->redirect($this->generateUrl('homepage')); | 99 | return $this->redirect($this->generateUrl('homepage')); |
119 | } | 100 | } |
101 | |||
102 | /** | ||
103 | * Return Pocket Import Service with or without RabbitMQ enabled. | ||
104 | * | ||
105 | * @return \Wallabag\ImportBundle\Import\PocketImport | ||
106 | */ | ||
107 | private function getPocketImportService() | ||
108 | { | ||
109 | $pocket = $this->get('wallabag_import.pocket.import'); | ||
110 | $pocket->setUser($this->getUser()); | ||
111 | |||
112 | if ($this->get('craue_config')->get('import_with_rabbitmq')) { | ||
113 | $pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer')); | ||
114 | } elseif ($this->get('craue_config')->get('import_with_redis')) { | ||
115 | $pocket->setProducer($this->get('wallabag_import.producer.redis.pocket')); | ||
116 | } | ||
117 | |||
118 | return $pocket; | ||
119 | } | ||
120 | } | 120 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php index aa732ddd..59de24cb 100644 --- a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php +++ b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\ImportBundle\Controller; | 3 | namespace Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Wallabag\ImportBundle\Form\Type\UploadImportType; | 8 | use Wallabag\ImportBundle\Form\Type\UploadImportType; |
9 | 9 | ||
@@ -29,11 +29,11 @@ class ReadabilityController extends Controller | |||
29 | if ($form->isSubmitted() && $form->isValid()) { | 29 | if ($form->isSubmitted() && $form->isValid()) { |
30 | $file = $form->get('file')->getData(); | 30 | $file = $form->get('file')->getData(); |
31 | $markAsRead = $form->get('mark_as_read')->getData(); | 31 | $markAsRead = $form->get('mark_as_read')->getData(); |
32 | $name = 'readability_'.$this->getUser()->getId().'.json'; | 32 | $name = 'readability_' . $this->getUser()->getId() . '.json'; |
33 | 33 | ||
34 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | 34 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { |
35 | $res = $readability | 35 | $res = $readability |
36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | 36 | ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name) |
37 | ->setMarkAsRead($markAsRead) | 37 | ->setMarkAsRead($markAsRead) |
38 | ->import(); | 38 | ->import(); |
39 | 39 | ||
@@ -52,7 +52,7 @@ class ReadabilityController extends Controller | |||
52 | ]); | 52 | ]); |
53 | } | 53 | } |
54 | 54 | ||
55 | unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); | 55 | unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name); |
56 | } | 56 | } |
57 | 57 | ||
58 | $this->get('session')->getFlashBag()->add( | 58 | $this->get('session')->getFlashBag()->add( |
@@ -61,12 +61,12 @@ class ReadabilityController extends Controller | |||
61 | ); | 61 | ); |
62 | 62 | ||
63 | return $this->redirect($this->generateUrl('homepage')); | 63 | return $this->redirect($this->generateUrl('homepage')); |
64 | } else { | ||
65 | $this->get('session')->getFlashBag()->add( | ||
66 | 'notice', | ||
67 | 'flashes.import.notice.failed_on_file' | ||
68 | ); | ||
69 | } | 64 | } |
65 | |||
66 | $this->get('session')->getFlashBag()->add( | ||
67 | 'notice', | ||
68 | 'flashes.import.notice.failed_on_file' | ||
69 | ); | ||
70 | } | 70 | } |
71 | 71 | ||
72 | return $this->render('WallabagImportBundle:Readability:index.html.twig', [ | 72 | return $this->render('WallabagImportBundle:Readability:index.html.twig', [ |
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagController.php b/src/Wallabag/ImportBundle/Controller/WallabagController.php index e81c1ca9..6e6524b4 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagController.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagController.php | |||
@@ -3,7 +3,9 @@ | |||
3 | namespace Wallabag\ImportBundle\Controller; | 3 | namespace Wallabag\ImportBundle\Controller; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6 | use Symfony\Component\HttpFoundation\RedirectResponse; | ||
6 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Symfony\Component\HttpFoundation\Response; | ||
7 | use Wallabag\ImportBundle\Form\Type\UploadImportType; | 9 | use Wallabag\ImportBundle\Form\Type\UploadImportType; |
8 | 10 | ||
9 | /** | 11 | /** |
@@ -12,20 +14,6 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType; | |||
12 | abstract class WallabagController extends Controller | 14 | abstract class WallabagController extends Controller |
13 | { | 15 | { |
14 | /** | 16 | /** |
15 | * Return the service to handle the import. | ||
16 | * | ||
17 | * @return \Wallabag\ImportBundle\Import\ImportInterface | ||
18 | */ | ||
19 | abstract protected function getImportService(); | ||
20 | |||
21 | /** | ||
22 | * Return the template used for the form. | ||
23 | * | ||
24 | * @return string | ||
25 | */ | ||
26 | abstract protected function getImportTemplate(); | ||
27 | |||
28 | /** | ||
29 | * Handle import request. | 17 | * Handle import request. |
30 | * | 18 | * |
31 | * @param Request $request | 19 | * @param Request $request |
@@ -43,11 +31,11 @@ abstract class WallabagController extends Controller | |||
43 | if ($form->isSubmitted() && $form->isValid()) { | 31 | if ($form->isSubmitted() && $form->isValid()) { |
44 | $file = $form->get('file')->getData(); | 32 | $file = $form->get('file')->getData(); |
45 | $markAsRead = $form->get('mark_as_read')->getData(); | 33 | $markAsRead = $form->get('mark_as_read')->getData(); |
46 | $name = $this->getUser()->getId().'.json'; | 34 | $name = $this->getUser()->getId() . '.json'; |
47 | 35 | ||
48 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { | 36 | if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { |
49 | $res = $wallabag | 37 | $res = $wallabag |
50 | ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) | 38 | ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name) |
51 | ->setMarkAsRead($markAsRead) | 39 | ->setMarkAsRead($markAsRead) |
52 | ->import(); | 40 | ->import(); |
53 | 41 | ||
@@ -66,7 +54,7 @@ abstract class WallabagController extends Controller | |||
66 | ]); | 54 | ]); |
67 | } | 55 | } |
68 | 56 | ||
69 | unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); | 57 | unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name); |
70 | } | 58 | } |
71 | 59 | ||
72 | $this->get('session')->getFlashBag()->add( | 60 | $this->get('session')->getFlashBag()->add( |
@@ -75,12 +63,12 @@ abstract class WallabagController extends Controller | |||
75 | ); | 63 | ); |
76 | 64 | ||
77 | return $this->redirect($this->generateUrl('homepage')); | 65 | return $this->redirect($this->generateUrl('homepage')); |
78 | } else { | ||
79 | $this->get('session')->getFlashBag()->add( | ||
80 | 'notice', | ||
81 | 'flashes.import.notice.failed_on_file' | ||
82 | ); | ||
83 | } | 66 | } |
67 | |||
68 | $this->get('session')->getFlashBag()->add( | ||
69 | 'notice', | ||
70 | 'flashes.import.notice.failed_on_file' | ||
71 | ); | ||
84 | } | 72 | } |
85 | 73 | ||
86 | return $this->render($this->getImportTemplate(), [ | 74 | return $this->render($this->getImportTemplate(), [ |
@@ -88,4 +76,18 @@ abstract class WallabagController extends Controller | |||
88 | 'import' => $wallabag, | 76 | 'import' => $wallabag, |
89 | ]); | 77 | ]); |
90 | } | 78 | } |
79 | |||
80 | /** | ||
81 | * Return the service to handle the import. | ||
82 | * | ||
83 | * @return \Wallabag\ImportBundle\Import\ImportInterface | ||
84 | */ | ||
85 | abstract protected function getImportService(); | ||
86 | |||
87 | /** | ||
88 | * Return the template used for the form. | ||
89 | * | ||
90 | * @return string | ||
91 | */ | ||
92 | abstract protected function getImportTemplate(); | ||
91 | } | 93 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php index 312c7a35..d700d8a8 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php | |||
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request; | |||
8 | class WallabagV1Controller extends WallabagController | 8 | class WallabagV1Controller extends WallabagController |
9 | { | 9 | { |
10 | /** | 10 | /** |
11 | * @Route("/wallabag-v1", name="import_wallabag_v1") | ||
12 | */ | ||
13 | public function indexAction(Request $request) | ||
14 | { | ||
15 | return parent::indexAction($request); | ||
16 | } | ||
17 | |||
18 | /** | ||
11 | * {@inheritdoc} | 19 | * {@inheritdoc} |
12 | */ | 20 | */ |
13 | protected function getImportService() | 21 | protected function getImportService() |
@@ -30,12 +38,4 @@ class WallabagV1Controller extends WallabagController | |||
30 | { | 38 | { |
31 | return 'WallabagImportBundle:WallabagV1:index.html.twig'; | 39 | return 'WallabagImportBundle:WallabagV1:index.html.twig'; |
32 | } | 40 | } |
33 | |||
34 | /** | ||
35 | * @Route("/wallabag-v1", name="import_wallabag_v1") | ||
36 | */ | ||
37 | public function indexAction(Request $request) | ||
38 | { | ||
39 | return parent::indexAction($request); | ||
40 | } | ||
41 | } | 41 | } |
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php index 45211fe6..ab26400c 100644 --- a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php +++ b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php | |||
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request; | |||
8 | class WallabagV2Controller extends WallabagController | 8 | class WallabagV2Controller extends WallabagController |
9 | { | 9 | { |
10 | /** | 10 | /** |
11 | * @Route("/wallabag-v2", name="import_wallabag_v2") | ||
12 | */ | ||
13 | public function indexAction(Request $request) | ||
14 | { | ||
15 | return parent::indexAction($request); | ||
16 | } | ||
17 | |||
18 | /** | ||
11 | * {@inheritdoc} | 19 | * {@inheritdoc} |
12 | */ | 20 | */ |
13 | protected function getImportService() | 21 | protected function getImportService() |
@@ -30,12 +38,4 @@ class WallabagV2Controller extends WallabagController | |||
30 | { | 38 | { |
31 | return 'WallabagImportBundle:WallabagV2:index.html.twig'; | 39 | return 'WallabagImportBundle:WallabagV2:index.html.twig'; |
32 | } | 40 | } |
33 | |||
34 | /** | ||
35 | * @Route("/wallabag-v2", name="import_wallabag_v2") | ||
36 | */ | ||
37 | public function indexAction(Request $request) | ||
38 | { | ||
39 | return parent::indexAction($request); | ||
40 | } | ||
41 | } | 41 | } |