<?php
namespace App\Console\Sales;
use App\Repository\CityRepository;
use App\Repository\ProfileAdBoardPlacementRepository;
use App\Service\Features;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class FixProfileAdBoardPositionsCommand extends Command
{
public function __construct(
private CityRepository $cityRepository,
private ProfileAdBoardPlacementRepository $placementRepository,
private Features $features,
)
{
parent::__construct();
}
/**
* @inheritDoc
*/
protected function configure()
{
$this->setName('sales:profile:adboard:align-positions');
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
if(false === $this->features->adboard_positions_alignment_by_schedule()) {
$io->warning('Feature FEATURE_ADBOARD_POSITIONS_ALIGNMENT_BY_SCHEDULE is disabled');
return Command::INVALID;
}
$io->title('Aligning profile adboard placements');
$io->progressStart();
foreach ($this->cityRepository->iterateAll() as $city) {
$io->writeln('City:' . $city->getName());
$this->placementRepository->alignAdBoardStandardPositions($city);
$this->placementRepository->alignAdBoardVipPositions($city);
$this->placementRepository->alignAdBoardUltraVipPositions($city);
$io->progressAdvance();
}
$io->progressFinish();
$io->success('Success aligning profile placement positions');
return Command::SUCCESS;
}
}