Use FQCN as service name for UserRepository

This commit is contained in:
Yassine Guedidi
2022-04-24 16:09:34 +02:00
parent 97a4e826b5
commit ff9f719ec5
11 changed files with 39 additions and 32 deletions

View File

@ -10,6 +10,7 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Repository\UserRepository;
class CleanDuplicatesCommand extends ContainerAwareCommand
{
@ -49,7 +50,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
$this->io->success('Finished cleaning.');
} else {
$users = $this->getContainer()->get('wallabag_user.user_repository')->findAll();
$users = $this->getContainer()->get(UserRepository::class)->findAll();
$this->io->text(sprintf('Cleaning through <info>%d</info> user accounts', \count($users)));
@ -109,6 +110,6 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
*/
private function getUser($username)
{
return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username);
return $this->getContainer()->get(UserRepository::class)->findOneByUserName($username);
}
}

View File

@ -8,6 +8,7 @@ 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\UserBundle\Repository\UserRepository;
class ExportCommand extends ContainerAwareCommand
{
@ -35,7 +36,7 @@ class ExportCommand extends ContainerAwareCommand
$io = new SymfonyStyle($input, $output);
try {
$user = $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($input->getArgument('username'));
$user = $this->getContainer()->get(UserRepository::class)->findOneByUserName($input->getArgument('username'));
} catch (NoResultException $e) {
$io->error(sprintf('User "%s" not found.', $input->getArgument('username')));

View File

@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\UserBundle\Repository\UserRepository;
class ListUserCommand extends ContainerAwareCommand
{
@ -26,13 +27,13 @@ class ListUserCommand extends ContainerAwareCommand
{
$io = new SymfonyStyle($input, $output);
$users = $this->getContainer()->get('wallabag_user.user_repository')
$users = $this->getContainer()->get(UserRepository::class)
->getQueryBuilderForSearch($input->getArgument('search'))
->setMaxResults($input->getOption('limit'))
->getQuery()
->getResult();
$nbUsers = $this->getContainer()->get('wallabag_user.user_repository')
$nbUsers = $this->getContainer()->get(UserRepository::class)
->getSumUsers();
$rows = [];

View File

@ -9,6 +9,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\CoreBundle\Event\EntrySavedEvent;
use Wallabag\UserBundle\Repository\UserRepository;
class ReloadEntryCommand extends ContainerAwareCommand
{
@ -30,7 +31,7 @@ class ReloadEntryCommand extends ContainerAwareCommand
if ($username = $input->getArgument('username')) {
try {
$userId = $this->getContainer()
->get('wallabag_user.user_repository')
->get(UserRepository::class)
->findOneByUserName($username)
->getId();
} catch (NoResultException $e) {

View File

@ -9,6 +9,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Repository\UserRepository;
class ShowUserCommand extends ContainerAwareCommand
{
@ -68,6 +69,6 @@ class ShowUserCommand extends ContainerAwareCommand
*/
private function getUser($username)
{
return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username);
return $this->getContainer()->get(UserRepository::class)->findOneByUserName($username);
}
}

View File

@ -8,6 +8,7 @@ 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\UserBundle\Repository\UserRepository;
class TagAllCommand extends ContainerAwareCommand
{
@ -63,7 +64,7 @@ class TagAllCommand extends ContainerAwareCommand
*/
private function getUser($username)
{
return $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($username);
return $this->getContainer()->get(UserRepository::class)->findOneByUserName($username);
}
private function getDoctrine()

View File

@ -25,6 +25,7 @@ use Wallabag\CoreBundle\Form\Type\TaggingRuleImportType;
use Wallabag\CoreBundle\Form\Type\TaggingRuleType;
use Wallabag\CoreBundle\Form\Type\UserInformationType;
use Wallabag\CoreBundle\Tools\Utils;
use Wallabag\UserBundle\Repository\UserRepository;
class ConfigController extends Controller
{
@ -236,7 +237,7 @@ class ConfigController extends Controller
],
'twofactor_auth' => $this->getParameter('twofactor_auth'),
'wallabag_url' => $this->getParameter('domain_name'),
'enabled_users' => $this->get('wallabag_user.user_repository')->getSumEnabledUsers(),
'enabled_users' => $this->get(UserRepository::class)->getSumEnabledUsers(),
]);
}
@ -594,7 +595,7 @@ class ConfigController extends Controller
*/
public function deleteAccountAction(Request $request)
{
$enabledUsers = $this->get('wallabag_user.user_repository')
$enabledUsers = $this->get(UserRepository::class)
->getSumEnabledUsers();
if ($enabledUsers <= 1) {