aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Controller/WallabagController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller/WallabagController.php')
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagController.php46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagController.php b/src/Wallabag/ImportBundle/Controller/WallabagController.php
index e81c1ca9..7b61805b 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagController.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagController.php
@@ -12,20 +12,6 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType;
12abstract class WallabagController extends Controller 12abstract class WallabagController extends Controller
13{ 13{
14 /** 14 /**
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. 15 * Handle import request.
30 * 16 *
31 * @param Request $request 17 * @param Request $request
@@ -43,11 +29,11 @@ abstract class WallabagController extends Controller
43 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
44 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
45 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
46 $name = $this->getUser()->getId().'.json'; 32 $name = $this->getUser()->getId() . '.json';
47 33
48 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)) {
49 $res = $wallabag 35 $res = $wallabag
50 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
51 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
52 ->import(); 38 ->import();
53 39
@@ -66,7 +52,7 @@ abstract class WallabagController extends Controller
66 ]); 52 ]);
67 } 53 }
68 54
69 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
70 } 56 }
71 57
72 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -75,12 +61,12 @@ abstract class WallabagController extends Controller
75 ); 61 );
76 62
77 return $this->redirect($this->generateUrl('homepage')); 63 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 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
84 } 70 }
85 71
86 return $this->render($this->getImportTemplate(), [ 72 return $this->render($this->getImportTemplate(), [
@@ -88,4 +74,18 @@ abstract class WallabagController extends Controller
88 'import' => $wallabag, 74 'import' => $wallabag,
89 ]); 75 ]);
90 } 76 }
77
78 /**
79 * Return the service to handle the import.
80 *
81 * @return \Wallabag\ImportBundle\Import\ImportInterface
82 */
83 abstract protected function getImportService();
84
85 /**
86 * Return the template used for the form.
87 *
88 * @return string
89 */
90 abstract protected function getImportTemplate();
91} 91}