diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Command')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/InstallCommand.php | 17 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Command/TagAllCommand.php | 5 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index cc7c2c94..8e438229 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -9,7 +9,7 @@ use Symfony\Component\Console\Helper\Table; | |||
9 | use Symfony\Component\Console\Input\ArrayInput; | 9 | use Symfony\Component\Console\Input\ArrayInput; |
10 | use Symfony\Component\Console\Input\InputInterface; | 10 | use Symfony\Component\Console\Input\InputInterface; |
11 | use Symfony\Component\Console\Input\InputOption; | 11 | use Symfony\Component\Console\Input\InputOption; |
12 | use Symfony\Component\Console\Output\NullOutput; | 12 | use Symfony\Component\Console\Output\BufferedOutput; |
13 | use Symfony\Component\Console\Output\OutputInterface; | 13 | use Symfony\Component\Console\Output\OutputInterface; |
14 | use Symfony\Component\Console\Question\ConfirmationQuestion; | 14 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
15 | use Symfony\Component\Console\Question\Question; | 15 | use Symfony\Component\Console\Question\Question; |
@@ -97,7 +97,8 @@ class InstallCommand extends ContainerAwareCommand | |||
97 | try { | 97 | try { |
98 | $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect(); | 98 | $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect(); |
99 | } catch (\Exception $e) { | 99 | } catch (\Exception $e) { |
100 | if (false === strpos($e->getMessage(), 'Unknown database')) { | 100 | if (false === strpos($e->getMessage(), 'Unknown database') |
101 | && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) { | ||
101 | $fulfilled = false; | 102 | $fulfilled = false; |
102 | $status = '<error>ERROR!</error>'; | 103 | $status = '<error>ERROR!</error>'; |
103 | $help = 'Can\'t connect to the database: '.$e->getMessage(); | 104 | $help = 'Can\'t connect to the database: '.$e->getMessage(); |
@@ -420,16 +421,18 @@ class InstallCommand extends ContainerAwareCommand | |||
420 | } | 421 | } |
421 | 422 | ||
422 | $this->getApplication()->setAutoExit(false); | 423 | $this->getApplication()->setAutoExit(false); |
423 | $exitCode = $this->getApplication()->run(new ArrayInput($parameters), new NullOutput()); | 424 | |
425 | $output = new BufferedOutput(); | ||
426 | $exitCode = $this->getApplication()->run(new ArrayInput($parameters), $output); | ||
424 | 427 | ||
425 | if (0 !== $exitCode) { | 428 | if (0 !== $exitCode) { |
426 | $this->getApplication()->setAutoExit(true); | 429 | $this->getApplication()->setAutoExit(true); |
427 | 430 | ||
428 | $errorMessage = sprintf('The command "%s" terminated with an error code: %u.', $command, $exitCode); | 431 | $this->defaultOutput->writeln(''); |
429 | $this->defaultOutput->writeln("<error>$errorMessage</error>"); | 432 | $this->defaultOutput->writeln('<error>The command "'.$command.'" generates some errors: </error>'); |
430 | $exception = new \Exception($errorMessage, $exitCode); | 433 | $this->defaultOutput->writeln($output->fetch()); |
431 | 434 | ||
432 | throw $exception; | 435 | die(); |
433 | } | 436 | } |
434 | 437 | ||
435 | // PDO does not always close the connection after Doctrine commands. | 438 | // PDO does not always close the connection after Doctrine commands. |
diff --git a/src/Wallabag/CoreBundle/Command/TagAllCommand.php b/src/Wallabag/CoreBundle/Command/TagAllCommand.php index db1a9ab7..3f9bb04d 100644 --- a/src/Wallabag/CoreBundle/Command/TagAllCommand.php +++ b/src/Wallabag/CoreBundle/Command/TagAllCommand.php | |||
@@ -34,10 +34,13 @@ class TagAllCommand extends ContainerAwareCommand | |||
34 | } | 34 | } |
35 | $tagger = $this->getContainer()->get('wallabag_core.rule_based_tagger'); | 35 | $tagger = $this->getContainer()->get('wallabag_core.rule_based_tagger'); |
36 | 36 | ||
37 | $output->write(sprintf('Tagging entries for user « <info>%s</info> »... ', $user->getUserName())); | 37 | $output->write(sprintf('Tagging entries for user « <comment>%s</comment> »... ', $user->getUserName())); |
38 | 38 | ||
39 | $entries = $tagger->tagAllForUser($user); | 39 | $entries = $tagger->tagAllForUser($user); |
40 | 40 | ||
41 | $output->writeln('<info>Done.</info>'); | ||
42 | $output->write(sprintf('Persist entries ... ', $user->getUserName())); | ||
43 | |||
41 | $em = $this->getDoctrine()->getManager(); | 44 | $em = $this->getDoctrine()->getManager(); |
42 | foreach ($entries as $entry) { | 45 | foreach ($entries as $entry) { |
43 | $em->persist($entry); | 46 | $em->persist($entry); |