]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Command/TagAllCommand.php
Merge remote-tracking branch 'origin/master' into 2.3
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Command / TagAllCommand.php
index db1a9ab79d3b28d361e7498b156a57dcc4f4e6b7..4afac2d45808fb5ee69e559afb59585538b2cae1 100644 (file)
@@ -7,6 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
 
 class TagAllCommand extends ContainerAwareCommand
 {
@@ -25,26 +26,32 @@ class TagAllCommand extends ContainerAwareCommand
 
     protected function execute(InputInterface $input, OutputInterface $output)
     {
+        $io = new SymfonyStyle($input, $output);
+
         try {
             $user = $this->getUser($input->getArgument('username'));
         } catch (NoResultException $e) {
-            $output->writeln(sprintf('<error>User "%s" not found.</error>', $input->getArgument('username')));
+            $io->error(sprintf('User "%s" not found.', $input->getArgument('username')));
 
             return 1;
         }
         $tagger = $this->getContainer()->get('wallabag_core.rule_based_tagger');
 
-        $output->write(sprintf('Tagging entries for user « <info>%s</info> »... ', $user->getUserName()));
+        $io->text(sprintf('Tagging entries for user <info>%s</info>...', $user->getUserName()));
 
         $entries = $tagger->tagAllForUser($user);
 
+        $io->text('Persist entries... ');
+
         $em = $this->getDoctrine()->getManager();
         foreach ($entries as $entry) {
             $em->persist($entry);
         }
         $em->flush();
 
-        $output->writeln('<info>Done.</info>');
+        $io->success('Done.');
+
+        return 0;
     }
 
     /**
@@ -56,7 +63,7 @@ class TagAllCommand extends ContainerAwareCommand
      */
     private function getUser($username)
     {
-        return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username);
+        return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username);
     }
 
     private function getDoctrine()