diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Command/TagAllCommand.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/TagAllCommand.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Command/TagAllCommand.php b/src/Wallabag/CoreBundle/Command/TagAllCommand.php index 3f9bb04d..4afac2d4 100644 --- a/src/Wallabag/CoreBundle/Command/TagAllCommand.php +++ b/src/Wallabag/CoreBundle/Command/TagAllCommand.php | |||
@@ -7,6 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | |||
7 | use Symfony\Component\Console\Input\InputArgument; | 7 | use Symfony\Component\Console\Input\InputArgument; |
8 | use Symfony\Component\Console\Input\InputInterface; | 8 | use Symfony\Component\Console\Input\InputInterface; |
9 | use Symfony\Component\Console\Output\OutputInterface; | 9 | use Symfony\Component\Console\Output\OutputInterface; |
10 | use Symfony\Component\Console\Style\SymfonyStyle; | ||
10 | 11 | ||
11 | class TagAllCommand extends ContainerAwareCommand | 12 | class TagAllCommand extends ContainerAwareCommand |
12 | { | 13 | { |
@@ -25,21 +26,22 @@ class TagAllCommand extends ContainerAwareCommand | |||
25 | 26 | ||
26 | protected function execute(InputInterface $input, OutputInterface $output) | 27 | protected function execute(InputInterface $input, OutputInterface $output) |
27 | { | 28 | { |
29 | $io = new SymfonyStyle($input, $output); | ||
30 | |||
28 | try { | 31 | try { |
29 | $user = $this->getUser($input->getArgument('username')); | 32 | $user = $this->getUser($input->getArgument('username')); |
30 | } catch (NoResultException $e) { | 33 | } catch (NoResultException $e) { |
31 | $output->writeln(sprintf('<error>User "%s" not found.</error>', $input->getArgument('username'))); | 34 | $io->error(sprintf('User "%s" not found.', $input->getArgument('username'))); |
32 | 35 | ||
33 | return 1; | 36 | return 1; |
34 | } | 37 | } |
35 | $tagger = $this->getContainer()->get('wallabag_core.rule_based_tagger'); | 38 | $tagger = $this->getContainer()->get('wallabag_core.rule_based_tagger'); |
36 | 39 | ||
37 | $output->write(sprintf('Tagging entries for user « <comment>%s</comment> »... ', $user->getUserName())); | 40 | $io->text(sprintf('Tagging entries for user <info>%s</info>...', $user->getUserName())); |
38 | 41 | ||
39 | $entries = $tagger->tagAllForUser($user); | 42 | $entries = $tagger->tagAllForUser($user); |
40 | 43 | ||
41 | $output->writeln('<info>Done.</info>'); | 44 | $io->text('Persist entries... '); |
42 | $output->write(sprintf('Persist entries ... ', $user->getUserName())); | ||
43 | 45 | ||
44 | $em = $this->getDoctrine()->getManager(); | 46 | $em = $this->getDoctrine()->getManager(); |
45 | foreach ($entries as $entry) { | 47 | foreach ($entries as $entry) { |
@@ -47,7 +49,9 @@ class TagAllCommand extends ContainerAwareCommand | |||
47 | } | 49 | } |
48 | $em->flush(); | 50 | $em->flush(); |
49 | 51 | ||
50 | $output->writeln('<info>Done.</info>'); | 52 | $io->success('Done.'); |
53 | |||
54 | return 0; | ||
51 | } | 55 | } |
52 | 56 | ||
53 | /** | 57 | /** |
@@ -59,7 +63,7 @@ class TagAllCommand extends ContainerAwareCommand | |||
59 | */ | 63 | */ |
60 | private function getUser($username) | 64 | private function getUser($username) |
61 | { | 65 | { |
62 | return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username); | 66 | return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username); |
63 | } | 67 | } |
64 | 68 | ||
65 | private function getDoctrine() | 69 | private function getDoctrine() |