]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Command/TagAllCommand.php
User existing service instead of getDoctrine
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Command / TagAllCommand.php
index 2cf3f80842e5fc1bc27b14fcd336eaecc5cf5c69..5a6dc04e359d963c160f629d1f115e2ffe262f68 100644 (file)
@@ -28,16 +28,19 @@ class TagAllCommand extends ContainerAwareCommand
         try {
             $user = $this->getUser($input->getArgument('username'));
         } catch (NoResultException $e) {
-            $output->writeln(sprintf('<error>User %s not found.</error>', $input->getArgument('username')));
+            $output->writeln(sprintf('<error>User "%s" not found.</error>', $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()));
+        $output->write(sprintf('Tagging entries for user « <comment>%s</comment> »... ', $user->getUserName()));
 
         $entries = $tagger->tagAllForUser($user);
 
+        $output->writeln('<info>Done.</info>');
+        $output->write(sprintf('Persist entries ... ', $user->getUserName()));
+
         $em = $this->getDoctrine()->getManager();
         foreach ($entries as $entry) {
             $em->persist($entry);
@@ -56,7 +59,7 @@ class TagAllCommand extends ContainerAwareCommand
      */
     private function getUser($username)
     {
-        return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username);
+        return $this->get('wallabag_user.user_repository')->findOneByUserName($username);
     }
 
     private function getDoctrine()