mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-27 03:21:01 +00:00
userId is now set in parameters
This commit is contained in:
parent
56ea1de99b
commit
a1bb1b3c2a
1 changed files with 10 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
||||||
namespace Wallabag\CoreBundle\Command;
|
namespace Wallabag\CoreBundle\Command;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Helper\ProgressBar;
|
use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
|
@ -15,7 +16,12 @@ class ImportCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('import:json')
|
->setName('import:json')
|
||||||
->setDescription('Import entries from JSON file');
|
->setDescription('Import entries from JSON file')
|
||||||
|
->addArgument(
|
||||||
|
'userId',
|
||||||
|
InputArgument::REQUIRED,
|
||||||
|
'user ID to populate'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
@ -32,6 +38,8 @@ class ImportCommand extends ContainerAwareCommand
|
||||||
|
|
||||||
protected function import(InputInterface $input, OutputInterface $output)
|
protected function import(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$userId = $input->getArgument('userId');
|
||||||
|
|
||||||
// Getting php array of data from CSV
|
// Getting php array of data from CSV
|
||||||
$data = $this->get($input, $output);
|
$data = $this->get($input, $output);
|
||||||
|
|
||||||
|
@ -48,7 +56,7 @@ class ImportCommand extends ContainerAwareCommand
|
||||||
$progress->start();
|
$progress->start();
|
||||||
|
|
||||||
$user = $em->getRepository('WallabagCoreBundle:User')
|
$user = $em->getRepository('WallabagCoreBundle:User')
|
||||||
->findOneById(1);
|
->findOneById($userId);
|
||||||
|
|
||||||
foreach ($data as $object) {
|
foreach ($data as $object) {
|
||||||
$array = (array) $object;
|
$array = (array) $object;
|
||||||
|
|
Loading…
Reference in a new issue