User existing service instead of getDoctrine

This commit is contained in:
Jeremy Benoist
2017-06-10 12:33:58 +02:00
parent 80784b782b
commit 25203e5081
8 changed files with 32 additions and 37 deletions

View File

@ -46,7 +46,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
return 1;
}
} else {
$users = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findAll();
$users = $this->get('wallabag_user.user_repository')->findAll();
$output->writeln(sprintf('Cleaning through %d user accounts', count($users)));
@ -66,7 +66,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
private function cleanDuplicates(User $user)
{
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
$repo = $this->get('wallabag_core.entry_repository');
$entries = $repo->getAllEntriesIdAndUrl($user->getId());
@ -109,7 +109,7 @@ class CleanDuplicatesCommand 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()

View File

@ -32,15 +32,14 @@ class ExportCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$user = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($input->getArgument('username'));
$user = $this->get('wallabag_user.user_repository')->findOneByUserName($input->getArgument('username'));
} catch (NoResultException $e) {
$output->writeln(sprintf('<error>User "%s" not found.</error>', $input->getArgument('username')));
return 1;
}
$entries = $this->getDoctrine()
->getRepository('WallabagCoreBundle:Entry')
$entries = $this->get('wallabag_core.entry_repository')
->getBuilderForAllByUser($user->getId())
->getQuery()
->getResult();

View File

@ -67,7 +67,7 @@ class ShowUserCommand 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()

View File

@ -59,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()