aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-09-30 15:10:46 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-01-02 23:24:17 +0100
commit8c3c77c1bd5c3763c127bfea52e908e77dc751b9 (patch)
treeb2e4dc1d22969748660da0fd7bd5fe0727081897 /src/Wallabag/CoreBundle/Controller
parenta1bb1b3c2a0631ad41262ef92f6cce02c3d376bf (diff)
downloadwallabag-8c3c77c1bd5c3763c127bfea52e908e77dc751b9.tar.gz
wallabag-8c3c77c1bd5c3763c127bfea52e908e77dc751b9.tar.zst
wallabag-8c3c77c1bd5c3763c127bfea52e908e77dc751b9.zip
create controller to launch import command
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ImportController.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ImportController.php b/src/Wallabag/CoreBundle/Controller/ImportController.php
new file mode 100644
index 00000000..53211eec
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Controller/ImportController.php
@@ -0,0 +1,40 @@
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;
11
12class ImportController extends Controller
13{
14 /**
15 * @param Request $request
16 *
17 * @Route("/import", name="import")
18 */
19 public function importAction(Request $request)
20 {
21 $command = new ImportCommand();
22 $command->setContainer($this->container);
23 $input = new ArrayInput(array('userId' => $this->getUser()->getId()));
24 $return = $command->run($input, new NullOutput());
25
26 if ($return == 0) {
27 $this->get('session')->getFlashBag()->add(
28 'notice',
29 'Import successful'
30 );
31 } else {
32 $this->get('session')->getFlashBag()->add(
33 'warning',
34 'Import failed'
35 );
36 }
37
38 return $this->redirect('/');
39 }
40}