aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-09-30 14:22:38 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-01-02 23:24:17 +0100
commita1bb1b3c2a0631ad41262ef92f6cce02c3d376bf (patch)
tree1e5023a8e03ce12d2264a8ec6a60dcfd6a07906f /src
parent56ea1de99bff55ce4149ea8070eabf8183d6f4fc (diff)
downloadwallabag-a1bb1b3c2a0631ad41262ef92f6cce02c3d376bf.tar.gz
wallabag-a1bb1b3c2a0631ad41262ef92f6cce02c3d376bf.tar.zst
wallabag-a1bb1b3c2a0631ad41262ef92f6cce02c3d376bf.zip
userId is now set in parameters
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Command/ImportCommand.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Command/ImportCommand.php b/src/Wallabag/CoreBundle/Command/ImportCommand.php
index f27aeff7..4a174202 100644
--- a/src/Wallabag/CoreBundle/Command/ImportCommand.php
+++ b/src/Wallabag/CoreBundle/Command/ImportCommand.php
@@ -3,6 +3,7 @@
3namespace Wallabag\CoreBundle\Command; 3namespace Wallabag\CoreBundle\Command;
4 4
5use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 5use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6use Symfony\Component\Console\Input\InputArgument;
6use Symfony\Component\Console\Input\InputInterface; 7use Symfony\Component\Console\Input\InputInterface;
7use Symfony\Component\Console\Output\OutputInterface; 8use Symfony\Component\Console\Output\OutputInterface;
8use Symfony\Component\Console\Helper\ProgressBar; 9use Symfony\Component\Console\Helper\ProgressBar;
@@ -15,7 +16,12 @@ class ImportCommand extends ContainerAwareCommand
15 { 16 {
16 $this 17 $this
17 ->setName('import:json') 18 ->setName('import:json')
18 ->setDescription('Import entries from JSON file'); 19 ->setDescription('Import entries from JSON file')
20 ->addArgument(
21 'userId',
22 InputArgument::REQUIRED,
23 'user ID to populate'
24 );
19 } 25 }
20 26
21 protected function execute(InputInterface $input, OutputInterface $output) 27 protected function execute(InputInterface $input, OutputInterface $output)
@@ -32,6 +38,8 @@ class ImportCommand extends ContainerAwareCommand
32 38
33 protected function import(InputInterface $input, OutputInterface $output) 39 protected function import(InputInterface $input, OutputInterface $output)
34 { 40 {
41 $userId = $input->getArgument('userId');
42
35 // Getting php array of data from CSV 43 // Getting php array of data from CSV
36 $data = $this->get($input, $output); 44 $data = $this->get($input, $output);
37 45
@@ -48,7 +56,7 @@ class ImportCommand extends ContainerAwareCommand
48 $progress->start(); 56 $progress->start();
49 57
50 $user = $em->getRepository('WallabagCoreBundle:User') 58 $user = $em->getRepository('WallabagCoreBundle:User')
51 ->findOneById(1); 59 ->findOneById($userId);
52 60
53 foreach ($data as $object) { 61 foreach ($data as $object) {
54 $array = (array) $object; 62 $array = (array) $object;