X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FCommand%2FCleanDuplicatesCommand.php;h=b58909db9f9c40b8c6cadbbdf25f27d7a8240a86;hb=2490f61dca635026a3eb9b5e9b6978b1981b1172;hp=b4aa4e470359cae82597b3173776876dee241aa7;hpb=e56f82142ac890c916b74700087424017bb2acf9;p=github%2Fwallabag%2Fwallabag.git
diff --git a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
index b4aa4e47..b58909db 100644
--- a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
+++ b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
@@ -7,13 +7,14 @@ 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;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\UserBundle\Entity\User;
class CleanDuplicatesCommand extends ContainerAwareCommand
{
- /** @var OutputInterface */
- protected $output;
+ /** @var SymfonyStyle */
+ protected $io;
protected $duplicates = 0;
@@ -32,7 +33,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
- $this->output = $output;
+ $this->io = new SymfonyStyle($input, $output);
$username = $input->getArgument('username');
@@ -41,20 +42,22 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
$user = $this->getUser($username);
$this->cleanDuplicates($user);
} catch (NoResultException $e) {
- $output->writeln(sprintf('User "%s" not found.', $username));
+ $this->io->error(sprintf('User "%s" not found.', $username));
return 1;
}
+
+ $this->io->success('Finished cleaning.');
} else {
$users = $this->getContainer()->get('wallabag_user.user_repository')->findAll();
- $output->writeln(sprintf('Cleaning through %d user accounts', count($users)));
+ $this->io->text(sprintf('Cleaning through %d user accounts', count($users)));
foreach ($users as $user) {
- $output->writeln(sprintf('Processing user %s', $user->getUsername()));
+ $this->io->text(sprintf('Processing user %s', $user->getUsername()));
$this->cleanDuplicates($user);
}
- $output->writeln(sprintf('Finished cleaning. %d duplicates found in total', $this->duplicates));
+ $this->io->success(sprintf('Finished cleaning. %d duplicates found in total', $this->duplicates));
}
return 0;
@@ -68,7 +71,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$repo = $this->getContainer()->get('wallabag_core.entry_repository');
- $entries = $repo->getAllEntriesIdAndUrl($user->getId());
+ $entries = $repo->findAllEntriesIdAndUrlByUserId($user->getId());
$duplicatesCount = 0;
$urls = [];
@@ -88,7 +91,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
$this->duplicates += $duplicatesCount;
- $this->output->writeln(sprintf('Cleaned %d duplicates for user %s', $duplicatesCount, $user->getUserName()));
+ $this->io->text(sprintf('Cleaned %d duplicates for user %s', $duplicatesCount, $user->getUserName()));
}
private function similarUrl($url)