src/Console/Sales/FixProfileAdBoardPositionsCommand.php line 47

Open in your IDE?
  1. <?php
  2. namespace App\Console\Sales;
  3. use App\Repository\CityRepository;
  4. use App\Repository\ProfileAdBoardPlacementRepository;
  5. use App\Service\Features;
  6. use Symfony\Component\Console\Command\Command;
  7. use Symfony\Component\Console\Input\InputInterface;
  8. use Symfony\Component\Console\Output\OutputInterface;
  9. use Symfony\Component\Console\Style\SymfonyStyle;
  10. class FixProfileAdBoardPositionsCommand extends Command
  11. {
  12.     public function __construct(
  13.         private CityRepository $cityRepository,
  14.         private ProfileAdBoardPlacementRepository $placementRepository,
  15.         private Features $features,
  16.     )
  17.     {
  18.         parent::__construct();
  19.     }
  20.     /**
  21.      * @inheritDoc
  22.      */
  23.     protected function configure()
  24.     {
  25.         $this->setName('sales:profile:adboard:align-positions');
  26.     }
  27.     /**
  28.      * @inheritDoc
  29.      */
  30.     protected function execute(InputInterface $inputOutputInterface $output): int
  31.     {
  32.         $io = new SymfonyStyle($input$output);
  33.         if(false === $this->features->adboard_positions_alignment_by_schedule()) {
  34.             $io->warning('Feature FEATURE_ADBOARD_POSITIONS_ALIGNMENT_BY_SCHEDULE is disabled');
  35.             return Command::INVALID;
  36.         }
  37.         $io->title('Aligning profile adboard placements');
  38.         $io->progressStart();
  39.         foreach ($this->cityRepository->iterateAll() as $city) {
  40.             $io->writeln('City:' $city->getName());
  41.             $this->placementRepository->alignAdBoardStandardPositions($city);
  42.             $this->placementRepository->alignAdBoardVipPositions($city);
  43.             $this->placementRepository->alignAdBoardUltraVipPositions($city);
  44.             $io->progressAdvance();
  45.         }
  46.         $io->progressFinish();
  47.         $io->success('Success aligning profile placement positions');
  48.         return Command::SUCCESS;
  49.     }
  50. }