2016-09-03 01:41:17 +00:00
|
|
|
<?php
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Console\Command;
|
2016-09-03 01:41:17 +00:00
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
use App\Radio\Configuration;
|
2018-11-12 16:59:15 +00:00
|
|
|
use Azura\Console\Command\CommandAbstract;
|
2016-09-27 04:16:34 +00:00
|
|
|
use Doctrine\ORM\EntityManager;
|
2018-08-04 22:05:14 +00:00
|
|
|
use App\Entity\Station;
|
2016-09-18 00:00:46 +00:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
2019-03-06 16:51:16 +00:00
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
2016-09-18 00:00:46 +00:00
|
|
|
|
2018-11-12 16:59:15 +00:00
|
|
|
class RestartRadio extends CommandAbstract
|
2016-09-03 01:41:17 +00:00
|
|
|
{
|
|
|
|
/**
|
2016-09-18 00:00:46 +00:00
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
protected function configure()
|
|
|
|
{
|
2017-06-18 02:11:01 +00:00
|
|
|
$this->setName('azuracast:radio:restart')
|
2016-09-18 00:00:46 +00:00
|
|
|
->setDescription('Restart all radio stations.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
2016-09-03 01:41:17 +00:00
|
|
|
*/
|
2016-09-18 00:00:46 +00:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
2016-09-03 01:41:17 +00:00
|
|
|
{
|
2019-03-06 16:51:16 +00:00
|
|
|
$io = new SymfonyStyle($input, $output);
|
2016-09-03 01:41:17 +00:00
|
|
|
|
2019-03-06 16:51:16 +00:00
|
|
|
$io->section('Restarting all radio stations...');
|
2016-12-13 05:20:17 +00:00
|
|
|
|
2016-09-27 04:16:34 +00:00
|
|
|
/** @var EntityManager $em */
|
2018-05-07 01:57:06 +00:00
|
|
|
$em = $this->get(EntityManager::class);
|
2018-02-01 11:49:40 +00:00
|
|
|
|
|
|
|
/** @var Configuration $configuration */
|
2018-05-07 01:57:06 +00:00
|
|
|
$configuration = $this->get(Configuration::class);
|
2018-02-01 11:49:40 +00:00
|
|
|
|
|
|
|
/** @var Station[] $stations */
|
2016-09-27 04:16:34 +00:00
|
|
|
$stations = $em->getRepository(Station::class)->findAll();
|
2016-09-03 01:41:17 +00:00
|
|
|
|
2019-03-06 16:51:16 +00:00
|
|
|
$io->progressStart(count($stations));
|
2016-12-13 05:20:17 +00:00
|
|
|
|
2017-01-24 00:35:16 +00:00
|
|
|
foreach ($stations as $station) {
|
2019-03-06 16:51:16 +00:00
|
|
|
$configuration->writeConfiguration($station, false, true);
|
2018-05-04 22:16:58 +00:00
|
|
|
|
|
|
|
$station->setHasStarted(true);
|
|
|
|
$station->setNeedsRestart(false);
|
|
|
|
|
|
|
|
$em->persist($station);
|
2019-03-06 16:51:16 +00:00
|
|
|
$em->flush($station);
|
|
|
|
|
|
|
|
$io->progressAdvance();
|
2016-09-03 01:41:17 +00:00
|
|
|
}
|
2016-12-13 05:20:17 +00:00
|
|
|
|
2019-03-06 16:51:16 +00:00
|
|
|
$io->progressFinish();
|
2018-05-07 01:57:06 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-03 01:41:17 +00:00
|
|
|
}
|
2018-08-04 22:05:14 +00:00
|
|
|
}
|