aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/ImportController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ImportController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ImportController.php64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ImportController.php b/src/Wallabag/CoreBundle/Controller/ImportController.php
deleted file mode 100644
index 33087710..00000000
--- a/src/Wallabag/CoreBundle/Controller/ImportController.php
+++ /dev/null
@@ -1,64 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\Console\Input\ArrayInput;
8use Symfony\Component\Console\Output\NullOutput;
9use Symfony\Component\HttpFoundation\Request;
10use Wallabag\CoreBundle\Command\ImportCommand;
11use Wallabag\CoreBundle\Form\Type\UploadImportType;
12
13class ImportController extends Controller
14{
15 /**
16 * @param Request $request
17 *
18 * @Route("/import", name="import")
19 */
20 public function importAction(Request $request)
21 {
22 $importForm = $this->createForm(new UploadImportType());
23 $importForm->handleRequest($request);
24 $user = $this->getUser();
25 $importConfig = $this->container->getParameter('wallabag_core.import');
26
27 if ($importForm->isValid()) {
28 $file = $importForm->get('file')->getData();
29 $name = $user->getId().'.json';
30 $dir = __DIR__.'/../../../../web/uploads/import';
31
32 if (in_array($file->getMimeType(), $importConfig['allow_mimetypes']) && $file->move($dir, $name)) {
33 $command = new ImportCommand();
34 $command->setContainer($this->container);
35 $input = new ArrayInput(array('userId' => $user->getId()));
36 $return = $command->run($input, new NullOutput());
37
38 if ($return == 0) {
39 $this->get('session')->getFlashBag()->add(
40 'notice',
41 'Import successful'
42 );
43 } else {
44 $this->get('session')->getFlashBag()->add(
45 'notice',
46 'Import failed'
47 );
48 }
49
50 return $this->redirect('/');
51 } else {
52 $this->get('session')->getFlashBag()->add(
53 'notice',
54 'Error while processing import. Please verify your import file.'
55 );
56 }
57 }
58
59 return $this->render('WallabagCoreBundle:Import:index.html.twig', array(
60 'form' => array(
61 'import' => $importForm->createView(), ),
62 ));
63 }
64}