diff options
Diffstat (limited to 'src/Wallabag')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/ImportCommand.php | 12 |
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 @@ | |||
3 | namespace Wallabag\CoreBundle\Command; | 3 | namespace Wallabag\CoreBundle\Command; |
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | 5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
6 | use Symfony\Component\Console\Input\InputArgument; | ||
6 | use Symfony\Component\Console\Input\InputInterface; | 7 | use Symfony\Component\Console\Input\InputInterface; |
7 | use Symfony\Component\Console\Output\OutputInterface; | 8 | use Symfony\Component\Console\Output\OutputInterface; |
8 | use Symfony\Component\Console\Helper\ProgressBar; | 9 | use 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; |