diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2015-12-30 10:06:45 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-02 23:27:41 +0100 |
commit | 77a7752a592af9ac821621a34d9955533baf40a0 (patch) | |
tree | 304b29f1d01a93a61f75f3206aabf845ff3fbe35 /src/Wallabag/CoreBundle/Controller | |
parent | 7ec2897ee0ad190dcb9f77032d785f2f9661b754 (diff) | |
download | wallabag-77a7752a592af9ac821621a34d9955533baf40a0.tar.gz wallabag-77a7752a592af9ac821621a34d9955533baf40a0.tar.zst wallabag-77a7752a592af9ac821621a34d9955533baf40a0.zip |
Update after previous merge
PR #1443 was merged into this branch to handle all import type in the same place.
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ImportController.php | 64 |
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 | |||
3 | namespace Wallabag\CoreBundle\Controller; | ||
4 | |||
5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Symfony\Component\Console\Input\ArrayInput; | ||
8 | use Symfony\Component\Console\Output\NullOutput; | ||
9 | use Symfony\Component\HttpFoundation\Request; | ||
10 | use Wallabag\CoreBundle\Command\ImportCommand; | ||
11 | use Wallabag\CoreBundle\Form\Type\UploadImportType; | ||
12 | |||
13 | class 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 | } | ||