1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-10-10 19:32:07 +00:00

Remove ContainerAwareCommand from commands

And use DI to retrieve services in commands (except for `RedisWorkerCommand` where the container is injected, hard to find a better way, at least for now).
This commit is contained in:
Jeremy Benoist 2022-12-15 20:57:02 +01:00
parent 9c16dd7bd1
commit 5832482a10
No known key found for this signature in database
GPG key ID: 7168D5DD29F38552
14 changed files with 290 additions and 169 deletions

View file

@ -3,7 +3,7 @@
namespace Wallabag\CoreBundle\Command;
use Doctrine\ORM\NoResultException;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -11,10 +11,17 @@ use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Repository\UserRepository;
class ShowUserCommand extends ContainerAwareCommand
class ShowUserCommand extends Command
{
/** @var SymfonyStyle */
protected $io;
protected SymfonyStyle $io;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
parent::__construct();
}
protected function configure()
{
@ -69,6 +76,6 @@ class ShowUserCommand extends ContainerAwareCommand
*/
private function getUser($username)
{
return $this->getContainer()->get(UserRepository::class)->findOneByUserName($username);
return $this->userRepository->findOneByUserName($username);
}
}