22
33namespace Silverback \ApiComponentsBundle \Command ;
44
5- use Doctrine \ORM \ EntityManagerInterface ;
5+ use Doctrine \Persistence \ ManagerRegistry ;
66use Silverback \ApiComponentsBundle \Entity \Core \AbstractComponent ;
77use Silverback \ApiComponentsBundle \Entity \Core \ComponentGroup ;
88use Silverback \ApiComponentsBundle \Helper \OrphanedResourceHelper ;
1515#[AsCommand(name: 'silverback:api-components:clean-orphaned ' )]
1616class CleanOrphanedCommand extends Command
1717{
18- public function __construct (private readonly OrphanedResourceHelper $ orphanedResourceHelper , private readonly EntityManagerInterface $ entityManager )
18+ public function __construct (private readonly OrphanedResourceHelper $ orphanedResourceHelper , private readonly ManagerRegistry $ registry )
1919 {
2020 parent ::__construct ();
2121 }
@@ -30,7 +30,7 @@ protected function configure(): void
3030 protected function execute (InputInterface $ input , OutputInterface $ output ): int
3131 {
3232 $ count = 0 ;
33- $ componentGroupRepository = $ this ->entityManager ->getRepository (ComponentGroup::class);
33+ $ componentGroupRepository = $ this ->registry ->getRepository (ComponentGroup::class);
3434 $ componentGroups = $ componentGroupRepository ->findAll ();
3535 $ groupsProgressBar = new ProgressBar ($ output , count ($ componentGroups ));
3636 $ groupsProgressBar ->start ();
@@ -42,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4242 }
4343 $ groupsProgressBar ->finish ();
4444
45- $ componentRepository = $ this ->entityManager ->getRepository (AbstractComponent::class);
45+ $ componentRepository = $ this ->registry ->getRepository (AbstractComponent::class);
4646 $ components = $ componentRepository ->findAll ();
4747 $ componentsProgressBar = new ProgressBar ($ output , count ($ componentGroups ));
4848 $ componentsProgressBar ->start ();
0 commit comments