diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ImportController.php | 40 |
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 | |||
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 | |||
12 | class 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 | } | ||