src/Console/Sales/RotateSaloonAdBoardPlacementsCommand.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Console\Sales;
  3. use App\Repository\CityRepository;
  4. use App\Repository\SaloonAdBoardPlacementRepository;
  5. use Symfony\Component\Console\Command\Command;
  6. use Symfony\Component\Console\Input\InputInterface;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. use Symfony\Component\Console\Style\SymfonyStyle;
  9. class RotateSaloonAdBoardPlacementsCommand extends Command
  10. {
  11.     public function __construct(
  12.         protected CityRepository $cityRepository,
  13.         protected SaloonAdBoardPlacementRepository $placementRepository
  14.     )
  15.     {
  16.         parent::__construct();
  17.     }
  18.     /**
  19.      * @inheritDoc
  20.      */
  21.     protected function configure()
  22.     {
  23.         $this->setName('sales:saloon:adboard:rotate');
  24.     }
  25.     /**
  26.      * @inheritDoc
  27.      */
  28.     protected function execute(InputInterface $inputOutputInterface $output): int
  29.     {
  30.         $io = new SymfonyStyle($input$output);
  31.         $io->title('Rotating saloon adboard placements');
  32.         $io->progressStart();
  33.         foreach ($this->cityRepository->findAll() as $city) {
  34.             $this->placementRepository->rotateAdBoardStandardPositions($city);
  35.             $this->placementRepository->rotateAdBoardVipPositions($city);
  36.             $this->placementRepository->rotateAdBoardUltraVipPositions($city);
  37.             $io->progressAdvance();
  38.         }
  39.         $io->progressFinish();
  40.         $io->success('Success rotating saloon placements');
  41.         return Command::SUCCESS;
  42.     }
  43. }